Skip to content

Commit 9dd6451

Browse files
committed
Add a JWTLeeway for LTI 1.3 JWT validation.
This is the maximum allowed difference between the exp and iat values in the JWT sent with a launch request. 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 exactly the current time. That is probably going to frequently be to strict. So this uses a default of 10 (perhaps 60 should be used here like the NoneLifeTime for LTI 1.1?). This is probably why many are experiencing issues with JWT tokens failing to validate.
1 parent 8896196 commit 9dd6451

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

conf/authen_LTI_1_3.conf.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ $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 JWTLeeway is the maximum allowed difference between the exp and
121+
# iat values in the token and the current time. If the JWTs in these launch requests are
122+
# failing to validate, then increase this value to allow for a larger difference between the exp
123+
# and iat values in the JWT and the current time.
124+
$LTI{v1p3}{JWTLeeway} = 10; # in seconds
125+
119126
################################################################################################
120127
# LTI 1.3 LMS Roles Mapped to WeBWorK Roles
121128
################################################################################################

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)