Skip to content

Conversation

@drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Jan 9, 2026

Currently the login capability of a user is only ever checked on initial sign in, and never again. So if a user logs in, and then the status or permission level of the user is changed so that the user no longer has the allow_course_access behavior or login permission level, then the user's current session remains valid, and the user may continue to work in the course (including submitting answers).

This changes that so that those things are checked on each request. So, for example, if a user is dropped (status changed to "D"), then the next thing the user tries to do in the course that involves a request to the server will result in the user being logged out.

This was reported for the Shibboleth authentication module in issue #2827, but really is an issue for all authentication modules. So this more generally fixes issue #2827 for all authentication modules.

This has been tested for all functional authentication modules (i.e., for all but the CAS and Moodle authentication modules. If the CAS module is fixed this should work for that as well. I plan to remove the Moodle authentication module in another pull request.

Note that this is done in such a way that no new database queries are needed. To make this happen the user record is cached in the check_user call, and then can be used any time after that. Future plans are to take this much further. There are many times in the code that the database record for the current user is fetched from the database, and now this cached user record from the current authentication module could directly be used instead.

Currently the login capability of a user is only ever checked on initial
sign in, and never again.  So if a user logs in, and then the status or
permission level of the user is changed so that the user no longer has
the `allow_course_access` behavior or `login` permission level, then the
user's current session remains valid, and the user may continue to work
in the course (including submitting answers).

This changes that so that those things are checked on each request.  So,
for example, if a user is dropped (status changed to "D"), then the next
thing the user tries to do in the course that involves a request to the
server will result in the user being logged out.

This was reported for the Shibboleth authentication module in issue openwebwork#2827,
but really is an issue for all authentication modules. So this more
generally fixes issue openwebwork#2827 for all authentication modules.

This has been tested for all functional authentication modules (i.e.,
for all but the `CAS` and `Moodle` authentication modules. If the `CAS`
module is fixed this should work for that as well.  I plan to remove the
`Moodle` authentication module in another pull request.

Note that this is done in such a way that no new database queries are
needed.  To make this happen the user record is cached in the
`check_user` call, and then can be used any time after that.  Future
plans are to take this much further.  There are many times in the code
that the database record for the current user is fetched from the
database, and now this cached user record from the current
authentication module could directly be used instead.
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.

1 participant