Skip to content

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Sep 2, 2025

Currently if $permissionLevels{login} = 'professor' and a user signs in via LTI that would be assigned the role of "student", then webwork2 creates the user and signs the user in. However, on subsequent LTI logins authentication fails. This refuses to create a user if the requested role would not have permission to login. @somiaj pointed this out recently in Slack.

Clean up the error messages some. There is a lot of work left to do on this. The LTIAdvance.pm module has an extremely poor design for error handling and messaging to go with those errors. The LTIAdvantage.pm module is only a tad better (I largely just copied the poor design of the LTIAdvanced.pm module). The log_error key is set and appended to numerous times, frequently resulting in a long run on message that doesn't really make sense. Also, there were some of these errors that were adding "LOGIN FAILED". That was removed because The Authen.pm code always prepends that and that resulted in logs with "LOGIN FAILED LOGIN FAILED ...".

The authenticate method is expected to return either 1 or a message indicating the failure. Currently it returns either 1 or 0. As a result the messages that are set in the authenticate method go into the abyss. Those messages should be returned instead of setting $self->{error}. Note that the method can still return 0 if no message should be set (as in the case of the OAuth token failing to verify for LTI 1.1).

For LTI 1.3 make sure that the fallback_source_of_username is set before attempting to use it. Otherwise the claim extraction fails and it results in a database error later.

@drgrice1 drgrice1 force-pushed the lti-issues branch 2 times, most recently from 5a26609 to 402521b Compare September 8, 2025 22:00
@drgrice1 drgrice1 force-pushed the lti-issues branch 2 times, most recently from d6810cd to ac7b42d Compare September 9, 2025 20:34
Comment on lines 288 to 289
debug("User |$user_id| is unknown but may be an new user from an LSM via LTI. "
. "Saw a value for $key About to return a 1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? "LSM"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed that typo.

Comment on lines 120 to 125
warn "LTI is not properly configured (no preferred_source_of_username). "
. "Please contact your instructor or system administrator.";
$self->{error} = $c->maketext("There was an error during the login process. "
. "Please speak to your instructor or system administrator.");
debug("No preferred_source_of_username in "
. $c->ce->{'courseName'}
. " so LTIAdvanced::get_credentials is returning a 0\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need these warn statements (here and below)? Wouldn't it be better to just show the user $self->{error} and put all releveant info in the debug() message. No need to state the page has errors, users who haven't enabled debugging shouldn't see that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. It has always been this way. I agree that a warning is not a good way to deal with this, but this is a warning that on a properly configured system will not be seen. Students should never see it. By the time students start signing in, the system will usually have been tested and properly configured.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the warning and made it so that it is only shown if debug_lti_parameters is set. I agree that this should not be shown to the end user, and that the $self->{error} is sufficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also did the same with the warn statement "below". It took me a bit to figure out which warn statement you were talking about "below". It is way below with several other warn statements in between.

@drgrice1 drgrice1 force-pushed the lti-issues branch 7 times, most recently from 0b0ac37 to 8dc953c Compare September 23, 2025 20:26
Currently if `$permissionLevels{login} = 'professor'` and a user signs
in via LTI that would be assigned the role of "student", then webwork2
creates the user and signs the user in.  However, on subsequent LTI
logins authentication fails.  This refuses to create a user if the
requested role would not have permission to login.

Clean up the error messages some.  There is a lot of work left to
do on this. The LTIAdvance.pm module has an extremely poor design for
error handling and messaging to go with those errors.  The
LTIAdvantage.pm module is only a tad better (I largely just copied the
poor design of the LTIAdvanced.pm module).  The `log_error` key is set
and appended to numerous times, frequently resulting in a long run on
message that doesn't really make sense. Also, there were some of these
errors that were adding "LOGIN FAILED".  That was removed because The
`Authen.pm` code always prepends that and that resulted in logs with
"LOGIN FAILED LOGIN FAILED ...".

The `authenticate` method is expected to return either 1 or a message
indicating the failure.  Currently it returns either 1 or 0.  As a
result the messages that are set in the `authenticate` method go into
the abyss.  Those messages should be returned instead of setting
`$self->{error}`. Note that the method can still return 0 if no message
should be set (as in the case of the OAuth token failing to verify for
LTI 1.1).

For LTI 1.3 make sure that the fallback_source_of_username is set before
attempting to use it. Otherwise the claim extraction fails and it
results in a database error later.

Fix a minor issue in the authen_LTI.conf.dist file.  The
permissionLevels lines should end with semicolons, not commas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants