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

feat: invalidate user session when user's role memberships changes #15633

Merged
merged 8 commits into from
Nov 14, 2023

Conversation

netroms
Copy link
Contributor

@netroms netroms commented Nov 9, 2023

Summary

  • The user will now be logged out of any current sessions when their role memberships are changed by an admin via the user admin UI or via an API call. Or if any of the assigned roles changes authorities, similarly. Without this feature, the user's new role assignments or role changes will not be effective in the ongoing sessions.

Automatic test

  • UserControllerTest#updateRolesShouldInvalidateUserSessions()

Manual test

Test role assignment will log out the users

  1. Create two users, one admin and one non-admin.
  2. As the admin user, create a superuser role that ass the “ALL” authority.
  3. As the admin user, assign the superuser role to the non-admin user.
  4. Log in as the non-admin user and try to edit a user in the user admin, this should work.
  5. As admin (in another browser), remove the superuser role from the non-admin user.
  6. As the non-admin user, try to go to any other page, you should now observe that you will be logged out and redirected to the login page.

Test role changes will log out the users

  1. Create two users, one admin and one non-admin.
  2. As the admin user, create a superuser role that ass the “ALL” authority.
  3. As the admin user, assign the superuser role to the non-admin user.
  4. Log in as the non-admin user and try to edit a user in the user admin, this should work.
  5. As admin (in another browser), remove the superuser “ALL” authority from the superuser role.
  6. As the non-admin user, try to go to any other page, you should now observe that you will be logged out and

Jira:

DHIS2-10334

@netroms netroms marked this pull request as draft November 9, 2023 06:42
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #15633 (53337ef) into master (94e33c8) will decrease coverage by 0.02%.
Report is 18 commits behind head on master.
The diff coverage is 97.61%.

@@             Coverage Diff              @@
##             master   #15633      +/-   ##
============================================
- Coverage     66.23%   66.21%   -0.02%     
- Complexity    31267    31279      +12     
============================================
  Files          3487     3488       +1     
  Lines        129811   129941     +130     
  Branches      15146    15176      +30     
============================================
+ Hits          85983    86044      +61     
- Misses        36748    36815      +67     
- Partials       7080     7082       +2     
Flag Coverage Δ
integration 49.79% <88.09%> (-0.02%) ⬇️
integration-h2 32.42% <92.85%> (+<0.01%) ⬆️
unit 30.31% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...in/java/org/hisp/dhis/user/CurrentUserService.java 84.37% <100.00%> (+8.18%) ⬆️
...in/java/org/hisp/dhis/user/DefaultUserService.java 62.77% <100.00%> (-0.31%) ⬇️
...adata/objectbundle/hooks/UserObjectBundleHook.java 68.50% <100.00%> (+2.98%) ⬆️
...etadata/objectbundle/hooks/UserRoleBundleHook.java 93.33% <93.33%> (ø)

... and 38 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94e33c8...53337ef. Read the comment docs.

@netroms netroms marked this pull request as ready for review November 10, 2023 04:43
Copy link

sonarcloud bot commented Nov 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@netroms netroms merged commit 4baf61c into master Nov 14, 2023
18 checks passed
@netroms netroms deleted the DHIS2-10334 branch November 14, 2023 02:29
netroms added a commit that referenced this pull request Jan 15, 2024
…15633)

* feat: invalidate user session when user's role memberships changes

(cherry picked from commit 4baf61c)
netroms added a commit that referenced this pull request Jan 15, 2024
…15633)

* feat: invalidate user session when user's role memberships changes

(cherry picked from commit 4baf61c)
netroms added a commit that referenced this pull request Jan 15, 2024
…15633)

* feat: invalidate user session when user's role memberships changes

(cherry picked from commit 4baf61c)
netroms added a commit that referenced this pull request Jan 15, 2024
…15633)

* feat: invalidate user session when user's role memberships changes

(cherry picked from commit 4baf61c)
netroms added a commit that referenced this pull request Jan 16, 2024
#16168)

* feat: invalidate user session when user's role memberships changes (#15633)
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.

3 participants