Skip to content

Commit

Permalink
Don't require $authen{admin_module} is a subset of $authen{user_module}.
Browse files Browse the repository at this point in the history
This changes the logic of how $authen{admin_module} is used to restrict
modules for the admin course. Instead of looping over all user_modules,
and requiring that module also be listed in admin_modules, only loop over
the modules listed in admin_modules when logging into the admin course.

This fixes an issue with LDAP (and maybe other authen modules), where
if they are listed in the user_module list, they have to also be listed
in the admin_module list, otherwise the error message generated for
this causes the authentication to fail.
  • Loading branch information
somiaj committed Aug 6, 2024
1 parent 9efc45d commit b60ac67
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lib/WeBWorK/Authen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ sub call_next_authen_method {
my $c = $self->{c};
my $ce = $c->{ce};

my $user_authen_module = WeBWorK::Authen::class($ce, "user_module");
my $user_authen_module =
$ce->{courseName} eq $ce->{admin_course_id}
? WeBWorK::Authen::class($ce, "admin_module")
: WeBWorK::Authen::class($ce, "user_module");
if (!defined $user_authen_module || $user_authen_module eq '') {
$self->{error} = $c->maketext(
"No authentication method found for your request. If this recurs, please speak with your instructor.");
Expand All @@ -155,18 +158,6 @@ sub verify {
debug('BEGIN VERIFY');

return $self->call_next_authen_method if !$self->request_has_data_for_this_verification_module;
my $authen_ref = ref($self);
if ($c->ce->{courseName} eq $c->ce->{admin_course_id}
&& !(grep {/^$authen_ref$/} @{ $c->ce->{authen}{admin_module} }))
{
$self->write_log_entry("Cannot authenticate into admin course using $authen_ref.");
$c->stash(
authen_error => $c->maketext(
'There was an error during the login process. Please speak to your instructor or system administrator.'
)
);
return $self->call_next_authen_method();
}

$self->{was_verified} = $self->do_verify;

Expand Down

0 comments on commit b60ac67

Please sign in to comment.