Add multi-key JWKS rotation for LTI 1.3 signing keys - #8056
Conversation
0757c80 to
fa67474
Compare
Coverage Report for CI Build 33513920385Coverage increased (+0.03%) to 90.727%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Naragod
left a comment
There was a problem hiding this comment.
Hey Donny, this is completely new to me, which took me a while to review with the assistance of Claude. I left a few comments based on my understanding of the code and what we are trying to do.
2dd6d6c to
0cfd0bc
Compare
0cfd0bc to
709c89f
Compare
709c89f to
6548519
Compare
Naragod
left a comment
There was a problem hiding this comment.
LGTM.
Rebase onto the latest master and you are good.
| - Forward the test batch id to the autotester so AI grading telemetry can attribute mass-grading runs (#7991) | ||
| - Removed Graders Subcomponent and added a Graders column in the Assignment Grades tab (#7967) | ||
| - Added GET /test_runs API route (#8055) | ||
| - Add multi-key JWKS rotation for LTI 1.3 signing keys (#8056) |
There was a problem hiding this comment.
Make sure to add this to the unreleased section when you update this branch
| resque: | ||
| permitted_hosts: [".localhost", ".internal"] | ||
|
|
||
| lti: |
There was a problem hiding this comment.
It's a bit strange to define these keys here and others in the development.yml/production.yml etc. Please merge these settings into those files.
| # The RSA key MarkUs signs NEW assertions with. | ||
| def current_key | ||
| path = explicit_current || key_paths.first | ||
| raise 'No LTI signing key found' if path.nil? |
There was a problem hiding this comment.
This error message and the one below should be internationalized
| def rotate! | ||
| FileUtils.mkdir_p(key_dir) | ||
| key = OpenSSL::PKey::RSA.new(2048) | ||
| path = File.join(key_dir, "lti_key_#{Time.now.utc.strftime('%Y%m%dT%H%M%SZ')}.pem") |
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
Summary
MarkUs signs LTI 1.3
client_credentialsassertions with a single RSA key and publishes exactly one key at/lti_deployments/public_jwk. Rotating it is therefore a hard swap — the outgoing key leaves the published JWKS the moment it stops signing, so assertions already in flight fail verification.This adds multi-key support with an overlap window, so keys can be rotated without disrupting grade passback (AGS) or roster sync (NRPS).
What changed
LtiKeyStore(new) manages a directory of timestamped PEMs:Settings.lti.rotation.current_key).public_jwkspublishes every key present, so a retired key still verifies until pruned.prune!removes keys retired longer ago than the overlap window, and never removes the current signer.LtiClient#get_oauth_tokenandLtiDeploymentsController#public_jwknow both go through the store, so signing and publication share one source of truth.LtiKeyMaintenanceJobruns daily viaresque-schedulerwhen enabled: rotates only if the current key is pastmax_age_days, prunes keys pastoverlap_days. Both are idempotent.Rake tasks remain for manual use, including compromise response:
markus:lti_key,markus:rotate_if_due,markus:prune_keys.Screenshots of your changes (if applicable)
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)