Skip to content

Commit 3f8d5a6

Browse files
authored
Merge pull request #2787 from drgrice1/lti-1.3-debug-hotfix
Add an LTI 1.3 debug log in the case that the JWT fails to decode on a launch request. (hotfix version)
2 parents 91e2017 + 0c11e3d commit 3f8d5a6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

conf/authen_LTI_1_3.conf.dist

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ $LTI{v1p3}{AuthReqURL} = '';
116116
# don't pile up in the database.
117117
$LTI{v1p3}{StateKeyLifetime} = 60; # in seconds
118118

119+
# When a LTI 1.3 launch request occurs the JWT in the request is decoded and the exp and iat in
120+
# the token are validated. The expectation is that the iat and exp values are before (less
121+
# than) the current time on the webwork2 server plus the JWTLeeway, and if they are greater than
122+
# the current time plus the JWTLeeway then the JWT fails to validate. So the JWTLeeway is the
123+
# maximum allowed time in seconds that the exp and iat values in the token are allowed to be
124+
# after the current time. If the JWTs in these launch requests are failing to validate, then
125+
# increase this value to allow for a larger difference between the exp and iat values in the JWT
126+
# and the current time. This is usually caused by the clock on the LMS server being ahead of the
127+
# clock on the webwork2 server. Generally, a small leeway may be needed, but if the clock on
128+
# the LMS server is too far ahead of the clock on the webwork2 server, then steps should be
129+
# taken to synchronize the clocks.
130+
$LTI{v1p3}{JWTLeeway} = 0; # in seconds
131+
119132
################################################################################################
120133
# LTI 1.3 LMS Roles Mapped to WeBWorK Roles
121134
################################################################################################

lib/WeBWorK/ContentGenerator/LTIAdvantage.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ sub launch ($c) {
161161
$c->stash->{lti_jwt_claims}{'https://purl.imsglobal.org/spec/lti/claim/context'}{id}
162162
]
163163
];
164+
} elsif ($c->stash->{LTIAuthenError}) {
165+
debug($c->stash->{LTIAuthenError});
164166
}
165167
return $c->render(
166168
'ContentGenerator/LTI/content_item_selection_error',
@@ -365,6 +367,7 @@ sub extract_jwt_claims ($c) {
365367
verify_aud => $ce->{LTI}{v1p3}{ClientID},
366368
verify_iat => 1,
367369
verify_exp => 1,
370+
leeway => $ce->{LTI}{v1p3}{JWTLeeway} // 0,
368371
# This just checks that this claim is present.
369372
verify_sub => sub ($value) { return $value =~ /\S/ }
370373
);

0 commit comments

Comments
 (0)