fix: EdDSA to Ed25519 token migration#786
Conversation
aldbr
left a comment
There was a problem hiding this comment.
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)
Documentation build overview
Show files changed (3 files in total): 📝 3 modified | ➕ 0 added | ➖ 0 deleted
|
Small documentationHow to rotate the keys:
How to check if rotation worked:
|
|
joserfc error breaking the demo when trying to login as diracAdmin:
Full Logs: See: https://jose.authlib.org/en/guide/errors/#unsupportedalgorithmerror Edit: error was due to wrong joserfc version in demo dependencies. |
|
I followed your steps on my side to check and I have a few minor comments 🙂
Note: you launch the demo only when you want to test the key rotation with
So here, if you try to decode the
Here you should use the updated script.
I think it's cleaner to update the existing secret with: kubectl create secret generic diracx-jwks \
--namespace="$namespace" \
--from-file=jwks.json \
--dry-run=client -o yaml \
| kubectl apply -f -You need to restart the kubectl rollout restart deployment diracx-demo -n $namespace
In the context of the demo, you also need to check the |
cc @aldbr
Closes: #718
Changes:
Documentation:
Token migration and keys rotation
The EdDSA token algorithm is being deprecated by RFC 9864, so it should be replaced with the Ed25519 token algorithm. To do this, users need to rotate their token keys using
diracxrotate function.Prerequisites:
joserfc >= 1.5.0, otherwise, it won't work.Important note:
Once the migration from EdDSA to Ed25519 is complete, it is recommended to rotate the Ed25519 keys after a certain period of time.
Locally (using DiracX demo) - only used as tests for this PR
{PATH}/run_demo {PATH}/diracxdiracx-charts. If you create the demo instance from this PR branch, it will automatically generate an Ed25519 key, preventing you from properly testing the migration/rotation process.joserfc >= 1.5.0before creating the demo instance. You will later need to switch branches, and without the correct joserfc version, the new Ed25519 implementation will not work properly.kubectl get secret diracx-jwks -o yaml, output:jwks.json:echo "{jwks.json.VALUE}" | base64 --decode > jwks.jsonjwks.jsonshould only contain"alg": "EdDSA"before migration.dirac login diracAdmin, it should work.jwks.json:python -m diracx.logic rotate-jwk --jwks-path jwks.jsonjwks.jsonshould now contain"alg": "EdDSA"and"alg": "Ed25519"kidvalues injwks.jsonfor later use.kubectl create secret generic diracx-jwks --namespace="$namespace" --from-file=jwks.json --dry-run=client -o yaml | kubectl apply -f -kubectl rollout restart deployment diracx-demoProduction
The following procedure applies both to:
kubectl get secretkubectl get secret {SECRET_TOKEN_ID} -o yaml, output:jwks.json:echo "{jwks.json.VALUE}" | base64 --decode > jwks.jsonjwks.jsonshould only contain"alg": "EdDSA"before migration.jwks.jsonanddiracxrotate function:python -m diracx.logic rotate-jwk --jwks-path jwks.jsonjwks.jsonshould now contain"alg": "EdDSA"and"alg": "Ed25519"kidvalues injwks.jsonfor later use.kubectl create secret generic {SECRET_TOKEN_ID} --namespace="$namespace" --from-file=jwks.json --dry-run=client -o yaml | kubectl apply -f -kubectl rollout restart deployment {POD_ID}Check-up after the rotation
Once migration and rotation are done:
.cache/diracx/credentials.jsonand verify that it contains"alg": "Ed25519".kidis different from new Ed25519 keykid(see step 6 (local) and step 5 (production), note 2)