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

Updating user roles, carefully #55

Open
jrchamp opened this issue Mar 20, 2019 · 1 comment
Open

Updating user roles, carefully #55

jrchamp opened this issue Mar 20, 2019 · 1 comment

Comments

@jrchamp
Copy link
Collaborator

jrchamp commented Mar 20, 2019

Based on https://wordpress.org/support/topic/update-user-roles/

Right now the Shibboleth plugin uses set_role() which removes all roles, even those that were added by other methods. The request is to only update the primary role, but I'm thinking an easier and safer way to define this is: "The Shibboleth plugin should only only update the role(s) that the Shibboleth plugin has granted."

Here’s my idea:

  1. Create a new usermeta that contains the “Shibboleth managed roles” for a user.
  2. Use the current set of “Shibboleth mapped roles” and the differences with the existing “Shibboleth managed roles” to determine whether to add or remove roles from a user.
    • This will require switching from set_role() to add_role() and remove_role()
  3. If we made changes to their role, we update the “Shibboleth managed roles” usermeta for that user.
    • Initially the value will not exist, but that’s okay because we only care when we are calling the “update roles” code. Thus: if blank, set to current “mapped roles” value; if not blank, compare to current “mapped roles” value and update if we make changes.

Thoughts? Worthwhile?

@michaelryanmcneill
Copy link
Owner

I think this is absolutely worthwhile. My only concern would be for changes in configuration between logins causing us to miss the removal of a role, but a secondary set of usermeta should properly account for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants