-
Notifications
You must be signed in to change notification settings - Fork 34
fix: EdDSA to Ed25519 token migration #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
aldbr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good, thank you 🙂
I just have a few minor comments around the tests.
Next step: making sure there is a documentation page to rotate the keys (and delete old ones if needed). If it does not exist, then we need to create one based on #499 (comment)
TODOs:Rotation:
How to check rotation:
|
|
joserfc error breaking the demo when trying to login as diracAdmin:
Full Logs: See: https://jose.authlib.org/en/guide/errors/#unsupportedalgorithmerror |
Tried to match their tests logic in our code: def create_token(payload: TokenPayload, settings: AuthSettings) -> str:
"""Create a JWT token with the given payload and settings."""
signing_key = None
for key in settings.token_keystore.jwks.keys:
key_ops = key.get("key_ops")
if key_ops and not isinstance(key_ops, list):
key_ops = [key_ops]
if key_ops and "sign" in key_ops:
signing_key = key
break
if not signing_key:
raise ValueError("No signing key found in JWKS")
# test logic here
algorithms = ["Ed25519"]
encoded_jwt = jwt.encode({"alg": "Ed25519"}, {}, signing_key, algorithms=algorithms)
jwt.decode(encoded_jwt, signing_key, algorithms=algorithms)Still the same error. What their {
"crv": "Ed25519",
"x": "t-nFRaxyM5DZcpg5lxiEeJcZpMRB8JgcKaQC0HRefXU",
"d": "gUF17HCe-pbN7Ej2rDSXl-e7uSj7rQW5u2dNu0KINP0",
"kty": "OKP",
"kid": "5V_IcL-iX5IbaNz9vg0CjXtWLZiJ94-ESnHI-HN1L2Y"
}Our {
"crv": "Ed25519",
"x": "OgKojQ4lAhaRjU_KF1vNkv99dnu8GRuDwkhdiAdsSJc",
"d": "skcpv4O3AR5GvITk2AA84H8AfhzXoth49TKTlE_dusM",
"key_ops": [
"sign",
"verify"
],
"alg": "Ed25519",
"kid": "019c4d8717dc75b1afc74172281b3b75",
"kty": "OKP"
} |
|
Tried to test the different keys @pytest.mark.parametrize(
"key", [
# joserfc key
({"crv": "Ed25519", "x": "t-nFRaxyM5DZcpg5lxiEeJcZpMRB8JgcKaQC0HRefXU", "d": "gUF17HCe-pbN7Ej2rDSXl-e7uSj7rQW5u2dNu0KINP0", "kty": "OKP", "kid": "5V_IcL-iX5IbaNz9vg0CjXtWLZiJ94-ESnHI-HN1L2Y"}),
# dirac key
({"crv": "Ed25519", "x": "OgKojQ4lAhaRjU_KF1vNkv99dnu8GRuDwkhdiAdsSJc", "d": "skcpv4O3AR5GvITk2AA84H8AfhzXoth49TKTlE_dusM", "key_ops": ["sign","verify"], "alg": "Ed25519", "kid": "019c4d8717dc75b1afc74172281b3b75", "kty": "OKP"})
]
)
def test_dummy(key):
from joserfc.jwk import OKPKey
from joserfc import jwt
ed25519_key = OKPKey.import_key(key)
algorithms = ["Ed25519"]
encoded_jwt = jwt.encode({"alg": "Ed25519"}, {}, ed25519_key, algorithms=algorithms)
jwt.decode(encoded_jwt, ed25519_key, algorithms=algorithms)Both test passed. Maybe Edit: |
cc @aldbr
Closes: #718
Changes:
TODO: