Skip to content
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

fix: include full-complement paramters in JWT_PRIVATE_SIGNING_JWK #925

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/20231020_143112_kyle_jwk_full_complement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Bugfix] Updated how the Tutor setting ``JWT_RSA_PRIVATE_KEY`` is rendered into the LMS Django setting ``JWT_AUTH['JWT_PRIVATE_SIGNING_JWK']`` as required by a recent breaking upstream change. The new representation of the ``JWT_PRIVATE_SIGNING_JWK`` simply adds the ``dq``, ``dp``, and ``qi`` parameters. Without this fix, LMS would encounter an ``InvalidKeyError`` on all logins (by @kdmccormick).
3 changes: 3 additions & 0 deletions tutor/templates/apps/openedx/settings/partials/common_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@
"n": "{{ jwt_rsa_key.n|long_to_base64 }}",
"p": "{{ jwt_rsa_key.p|long_to_base64 }}",
"q": "{{ jwt_rsa_key.q|long_to_base64 }}",
"dq": "{{ jwt_rsa_key.dq|long_to_base64 }}",
"dp": "{{ jwt_rsa_key.dp|long_to_base64 }}",
"qi": "{{ jwt_rsa_key.invq|long_to_base64 }}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes on confirming that this is correct:

RSA private numbers are represented with slightly different names in different libraries. n, e, d, p, and q always seem to have the same names. dp and dq aren't documented in pycryptodome (which is what Tutor is using here) but apparently they're present and have a matching definition (d mod (p - 1) and likewise for q.) For qi we can compare with PyJWT's translation from the cryptography library and see that cryptography's iqmp has the same definition as PyCryptodome's invq.

(The JWK spec doesn't actually define what qi is, but instead refers the reader to several print books.)

}
)
JWT_AUTH["JWT_PUBLIC_SIGNING_JWK_SET"] = json.dumps(
Expand Down