Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For LTI 1.3 only consider roles in the context for automatically created users. #2591

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -144,6 +144,12 @@ $LTI{v1p3}{LMSrolesToWeBWorKroles} = {
'Grader' => 'ta',
};

# The LMS reports roles context (or membership), instititution, and system
# roles. WeBWorK always ignores system roles, and also ignores institution
# roles by default. In some cases you may also want to consider institution
# roles. In that case set the following to 1.
$LTI{v1p3}{AllowInstitutionRoles} = 0;

################################################################################################
# Local routine to modify users
################################################################################################
Expand Down
9 changes: 7 additions & 2 deletions lib/WeBWorK/Authen/LTIAdvantage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,15 @@ sub create_user ($self) {
# Determine the roles defined for this user defined in the LTI request and assign a permission level on that basis.
my @LTIroles = @{ $self->{roles} };

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

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