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

Cleanup OpenID Connect Tokens not working #1467

Open
hdagheda opened this issue Nov 16, 2020 · 3 comments
Open

Cleanup OpenID Connect Tokens not working #1467

hdagheda opened this issue Nov 16, 2020 · 3 comments
Assignees
Labels
Feature - user sync Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - auth_oidc Plugin - local_o365

Comments

@hdagheda
Copy link
Contributor

Cleanup OpenID Connect Tokens not deleting object from local_o365_objects table. Even deleting token doesn't allow user to login again.

@weilai-irl weilai-irl self-assigned this Jan 8, 2021
@weilai-irl
Copy link
Collaborator

Hi @hdagheda,

The purpose of the "Cleanup OpenID Connect Tokens" feature is not to delete records from the mdl_local_o365_objects table. Rather, it looks for user OIDC tokens stored in the mdl_auth_oidc_token table that doesn't have a valid userid, and delete such tokens. It also shows records in mdl_auth_oidc_token table that contain tokens between potentially mismatched users, which helps site admins to troubleshoot SSO error.

If you have users who can't login, please look for the records of the user in the following tables:

  • mdl_local_o365_objects
  • mdl_auth_oidc_token
  • mdl_local_o365_connections (in case the user is manually connected)

I hope this helps.

Regards,
Lai

@AntonT76
Copy link

AntonT76 commented Mar 9, 2021

Dear @weilai-irl

we have a similar problem like @hdagheda :
In some cases we have to change existing usernames (eg username changes from u12345@xyz.com to u67890@xyz.com). It is the same user, but due to some organisational processes the user gets a new username. The old username will be deactivated/deleted.

In most of the cases the user has already done some activities in Moodle (eg upload homework, quiz, etc.) with his old username. These activities would be lost if we create a new user (eg u67890@xyz.com) and deactivate/delete the old user (eg u12345@xyz.com) in Moodle.

So what we do is to change the username directly in Moodle. It works fine, but it ends up in a Token error. The user could not login. To fix the token error, we have to edit the database (table: auth_oidc_token) and delete the entry of this user. Unfortunately, it is not easy because we do not always have access to the databases.

It would be nice if there is a possibility directly in the Maintenance Tool-Set of Office 365-Plugin Set - maybe in addition to the feature "Cleanup OpenID Connection Tokens" - where we can delete invalid token entries in the database "auth_oidc_token".

thanks,
best regards
Anton

@AntonT76
Copy link

Based on some tests I would like to make an addition. It might be possible to avoid a token error after changing the existing username in Moodle:

  1. login in Moodle as Moodle Admin
  2. go to o365-plugin-settings - Advanced - Connections - Manage User Connections
  3. disconnect the user
  4. enter a pseudo-password (user will be changed from OIDC to manual login authentication, a stored token will be deleted from the table prefix_auth_oidc_token)
  5. go to user settings, edit the user and change username - save entries
  6. edit user settings again - change authentication method from "manual" to "OpenID Connect"
  7. Finished.

Now, the user can login with the new login name. A new token will be stored in the table prefix_auth_oidc_token

I did some tests with one user, I hope, this method will work for all other users.

br, Anton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature - user sync Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - auth_oidc Plugin - local_o365
Projects
None yet
Development

No branches or pull requests

3 participants