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

Better cleanup of sharing roles on user purge #19096

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from

Conversation

jdavcs
Copy link
Member

@jdavcs jdavcs commented Nov 1, 2024

Builds on top of #18966 (depends on a relocated fixture from that PR, nothing more)

Currently, a user's email address is used in a sharing role's name. It's not practical to remove it because a sharing role must be identified somehow in the UI; it is possible to pull the current email for each associated user for each sharing role, but that seems like overkill, especially when multiple sharing roles need to be displayed, each potentially associated with multiple users. Using an email in the role name is for role description only: we don't retrieve roles based on email comparison anymore (fixed in #18942).

However, when a user is purged, we don't remove their email from associated sharing roles' names. This PR fixed this: we replace the user's email in the sharing role name with the string "[USER PURGED]", so a sharing role for john and alice, after john is purged, will appear as "sharing role for [USER PURGED], alice". If this sharing role has only one user association remaining with the user being purged, the role will be deleted. This also ensures there'll be no orphan sharing roles in the db (a sharing role without an associated user).

Test included.

To do in a follow-up: handle user email updates (in api/users.py) by updating email in sharing role name.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

jdavcs and others added 25 commits October 31, 2024 23:17
Now that role name doesn't have to be unique, we don't want to pass args
like "private role" or "shared role" on role creation.
Because we no longer can match role name to user email
Reason: decouple user email from private role naming: emails can be
changed or redacted; user id in user-role-association + role type is
sufficient to tie a user to a private role.

The description (i.e., "this is a private role for a user" is inferrable
from the role name ("private role"), which is assigned by default.
We must use a union because when we retrieve roles with a query, we
check against:
1) role name
2) email of associated user for private roles

We factor out this select into a helper method, which we then test
extensively.
Co-authored-by: David López <[email protected]>
Co-authored-by: David López <[email protected]>
1. Update sharing role name removing purged user email
2. If sharing role has only one user association, delete it.
3. Factor out cleanup, add test.

Note: this will not work if user email has been udpated after the sharing
role was created.
@jdavcs jdavcs added kind/bug kind/enhancement area/admin area/database Galaxy's database or data access layer labels Nov 1, 2024
@jdavcs jdavcs requested a review from a team November 1, 2024 03:31
@github-actions github-actions bot added this to the 24.2 milestone Nov 1, 2024
To accommodate package unit testing
lib/galaxy/webapps/galaxy/controllers/admin.py Outdated Show resolved Hide resolved
lib/galaxy/webapps/galaxy/controllers/admin.py Outdated Show resolved Hide resolved
lib/galaxy/webapps/galaxy/api/users.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants