Skip to content

Commit df4b848

Browse files
authored
Merge pull request openwebwork#2591 from drgrice1/lti-use-context-role-only
For LTI 1.3 only consider roles in the context for automatically created users.
2 parents f14d717 + 90f6209 commit df4b848

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

conf/authen_LTI_1_3.conf.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ $LTI{v1p3}{LMSrolesToWeBWorKroles} = {
144144
'Grader' => 'ta',
145145
};
146146

147+
# The LMS reports roles context (or membership), instititution, and system
148+
# roles. WeBWorK always ignores system roles, and also ignores institution
149+
# roles by default. In some cases you may also want to consider institution
150+
# roles. In that case set the following to 1.
151+
$LTI{v1p3}{AllowInstitutionRoles} = 0;
152+
147153
################################################################################################
148154
# Local routine to modify users
149155
################################################################################################

lib/WeBWorK/Authen/LTIAdvantage.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,15 @@ sub create_user ($self) {
369369
# Determine the roles defined for this user defined in the LTI request and assign a permission level on that basis.
370370
my @LTIroles = @{ $self->{roles} };
371371

372-
# Restrict to institution and context roles and remove the purl link portion (ignore system roles).
372+
# Restrict to context roles and remove the purl link portion. System roles are always ignored, but institution
373+
# roles are also included if $LTI{v1p3}{AllowInstitutionRoles} = 1.
373374
@LTIroles =
374375
map {s|^[^#]*#||r}
375-
grep {m!^http://purl.imsglobal.org/vocab/lis/v2/(membership|institution\/person)#!} @LTIroles;
376+
grep {
377+
m!^http://purl.imsglobal.org/vocab/lis/v2/membership#!
378+
|| ($ce->{LTI}{v1p3}{AllowInstitutionRoles}
379+
&& m!^http://purl.imsglobal.org/vocab/lis/v2/institution/person#!)
380+
} @LTIroles;
376381

377382
if ($ce->{debug_lti_parameters}) {
378383
warn "The adjusted LTI roles defined for this user are: \n-- " . join("\n-- ", @LTIroles),

0 commit comments

Comments
 (0)