Skip to content

Commit

Permalink
Add an $LTI{v1p3}{OverrideSiteProtocolDomain} LTI 1.3 configuration…
Browse files Browse the repository at this point in the history
… variable.

This is similar to the same named LTI 1.1 configuration variable.  It
should be set to a URL, and the protocol and domain name in the URL
replace the protocol and domain of the server as seen by the webwork2
app that is used for the issuer in the JWT sent to the LMS when
requesting an access token for grade passback.
  • Loading branch information
drgrice1 committed Feb 28, 2024
1 parent d944ceb commit 16e8305
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions conf/authen_LTI_1_3.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ $LTI{v1p3}{AccessTokenURL} = '';
$LTI{v1p3}{AccessTokenAUD} = '';
$LTI{v1p3}{AuthReqURL} = '';

# This allows you to declare the protocol and domain of the issuer used in the JWT that is sent
# when an access token is requested for grade passback from the LMS. These will replace the
# protocol and domain in the root url for this server.
$LTI{v1p1}{OverrideSiteProtocolDomain} = '';
#$LTI{v1p1}{OverrideSiteProtocolDomain} = 'https://vmwebwork42.myschool.edu';

# In the process of LTI 1.3 authentication a request is sent to the LMS in response to its
# request. State and nonce values are sent with this request, and those values must be verified
# in the next response from the LMS. These values are saved in the database so that they will
Expand Down
12 changes: 11 additions & 1 deletion lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,21 @@ async sub get_access_token ($self) {
return;
}

# The url of the request is used for the issuer by default. This
# can be overriden by the OverrideSiteProtocolDomain setting.
my $iss = $c->url_for('root')->to_abs;
if ($ce->{LTI}{v1p3}{OverrideSiteProtocolDomain}) {
my $override = Mojo::URL->new($ce->{LTI}{v1p3}{OverrideSiteProtocolDomain});
$iss->scheme($override->scheme);
$iss->host($override->host);
}
$c->log->info($iss);

my $jwt = eval {
encode_jwt(
payload => {
aud => $ce->{LTI}{v1p3}{AccessTokenAUD},
iss => $c->url_for('root')->to_abs->to_string,
iss => $iss,
sub => $ce->{LTI}{v1p3}{ClientID},
jti => $private_key->{kid}
},
Expand Down

0 comments on commit 16e8305

Please sign in to comment.