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

[1480] ui/auth: Query current user permissions to detect stale token #1569

Merged
merged 5 commits into from
Oct 28, 2022

Conversation

ssangervasi
Copy link
Contributor

@ssangervasi ssangervasi commented Oct 26, 2022

Closes #1480
Depends on API change: #1553

Code Changes

  • Query current user permissions to detect stale token
    • The important change!
    • ProtectedRoute will now kick the user to the login page if their client token is invalidated.
  • Add & use API models for the use-management feature
    • I let some of the aliases stick around because the names are actually nicer than the API one.
  • Remove some lingering code from unified merge
    • The auth slice middleware was deleted from ops, but made its way back by accident
    • The old ctl user state was unused.

Steps to Confirm

  1. Set up the test env
  2. Login as fidestest
  3. Navigate to a protected route (DSR)
  4. Teardown and recreate the test env
    • Or just delete the user client record from the DB
  5. Reload the page
    • You should be redirected to the login page
    • Going through the flow with a non-root user should work as well.

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Documentation Updated:
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Description Of Changes

The user permissions endpoint will allow users to query their own permissions. An invalid (expired) token will result in an error, which means the user is no longer authenticated. In addition to redirecting to the login page, the auth state is cleared from local storage.

We can also build on this in the future to have protected routes check for particular permissions instead of just success/error.

Fidesops PR 1409 replaced the original credential storage with the redux-persist logic.
The credential storage lines got reintroduced by a merge:

https://github.com/ethyca/fidesops/pull/1409/files#diff-af758411de81fed87d14012809b227b11c67ce770c998fd5059ea0769fbb5bd4L59

Unclear if this has caused any problems. My guess is that it's just been adding
an unused key to localStorage.
@ssangervasi ssangervasi changed the title Ssangervasi/fides 1480/expired client storage [1480] ui/auth: Query current user permissions to detect stale token Oct 26, 2022
@ssangervasi ssangervasi force-pushed the ssangervasi/fides-1480/expired-client-storage branch from c5411f7 to 3f32f70 Compare October 26, 2022 01:34
@Kelsey-Ethyca Kelsey-Ethyca merged commit 067dfbc into main Oct 28, 2022
@Kelsey-Ethyca Kelsey-Ethyca deleted the ssangervasi/fides-1480/expired-client-storage branch October 28, 2022 14:20
Kelsey-Ethyca added a commit that referenced this pull request Oct 28, 2022
@Kelsey-Ethyca Kelsey-Ethyca restored the ssangervasi/fides-1480/expired-client-storage branch October 28, 2022 18:09
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.

DSR execution doesn't show until you logout and log back in as admin
3 participants