Cache only the LTI 1.3 signing key actually needed from the LMS public keyset. (Hotfix of #3190) - #3191
Open
drgrice1 wants to merge 1 commit into
Open
Conversation
…c keyset. Only one key is ever actually needed to verify a given incoming JWT. Fetch the full keyset from the LMS when there's no cached key or the currently cached key does not work (presumably because it has expired), but don't cache it yet. Once the JWT has been decoded, pull the key from the keyset that is actually used to decode that JWT, and in the case that the keyset was just retrieved from the LMS, then cache just that one key. D2L Brightspace can serve a large number of keys in its keyset. It most likely uses a different public/private key for each external tool, and it seems that some D2L instances are even shared by multiple institutions in which case each institution has its own set of public/private keys in the keyset. When there are enough keys in the keyset its size can exceed the 64KB limit of the `TEXT` value field in the settings table. So caching only the needed key keeps that from happening. This should fix issue openwebwork#3189. This was also reported in https://forums.openwebwork.org/mod/forum/discuss.php?d=8834 (although I suspect those are really the same D2L instance as in the issue) and https://forums.openwebwork.org/mod/forum/discuss.php?d=8832. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
drgrice1
force-pushed
the
brightspace-keyset-oversized-hotfix
branch
from
September 2, 2026 19:52
9420bca to
7f2a002
Compare
dlglin
approved these changes
Sep 3, 2026
dlglin
left a comment
Member
There was a problem hiding this comment.
This works on our test D2L instance. Before this PR all keys from the keyset URL are stored to the WW DB. After the PR only one key is stored.
Note that checking out this PR didn't change the keys that were stored for any WW courses that were already linked to D2L, but that shouldn't be a problem. I was still able to log in to those courses, and anyone who ran into the "Data too long" error wouldn't have an entry saved to the DB.
Member
Author
|
Yeah, if there is already a valid keyset in the database it will be used. The format of what is stored is the same, just one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only one key is ever actually needed to verify a given incoming JWT. Fetch the full keyset from the LMS when there's no cached key or the currently cached key does not work (presumably because it has expired), but don't cache it yet. Once the JWT has been decoded, pull the key from the keyset that is actually used to decode that JWT, and in the case that the keyset was just retrieved from the LMS, then cache just that one key.
D2L Brightspace can serve a large number of keys in its keyset. It most likely uses a different public/private key for each external tool, and it seems that some D2L instances are even shared by multiple institutions in which case each institution has its own set of public/private keys in the keyset. When there are enough keys in the keyset its size can exceed the 64KB limit of the
TEXTvalue field in the settings table. So caching only the needed key keeps that from happening.This should fix issue #3189. This was also reported in https://forums.openwebwork.org/mod/forum/discuss.php?d=8834 (although I suspect those are really the same D2L instance as in the issue) and https://forums.openwebwork.org/mod/forum/discuss.php?d=8832.