Skip to content

Commit 410055d

Browse files
committed
Add a JWTLeeway for LTI 1.3 JWT validation.
This is the maximum number of seconds that exp and iat values in the JWT sent with a launch request are allowed to be in the future relative to the current time on the webwork2 server. The Crypt::JWT module by default uses a value of 0 for this, meaning that the iat and exp values in the token must be before the current time on the webwork2 server. This may be why many are experiencing issues with JWT tokens failing to validate, and is due to the clock on the LMS server being ahead of the clock on the webwork2 server. Generally such issues can be resolved by synchronizing clocks, but in some cases a small leeway may be needed.
1 parent 6225d59 commit 410055d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ sub extract_jwt_claims ($c) {
367367
verify_aud => $ce->{LTI}{v1p3}{ClientID},
368368
verify_iat => 1,
369369
verify_exp => 1,
370+
leeway => $ce->{LTI}{v1p3}{JWTLeeway} // 10,
370371
# This just checks that this claim is present.
371372
verify_sub => sub ($value) { return $value =~ /\S/ }
372373
);

0 commit comments

Comments
 (0)