-
Notifications
You must be signed in to change notification settings - Fork 357
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
fix: Check auth validity before setting isAuthenticated #8967
Conversation
✅ Deploy Preview for determined-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8967 +/- ##
==========================================
- Coverage 47.37% 42.60% -4.77%
==========================================
Files 1162 842 -320
Lines 176134 136791 -39343
Branches 2237 2236 -1
==========================================
- Hits 83448 58286 -25162
+ Misses 92528 78347 -14181
Partials 158 158
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing this!
Had some questions on the changes.
authStore.setAuth({ isAuthenticated: true, token: authToken }); | ||
}); | ||
} catch (e) { | ||
// If an invalid auth token is detected we need to properl handle the auth error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: if it fails, should the source of the token get cleared? Things like:
jwt
token from searchParamscookieToken
not sure if anything can or needs to be done hereglobalStorage.authToken
clear this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling handleError
ended up being the best approach here. I ran into unwanted beahvior/bugs otherwise. I am happy to delve into it though if need be.
The handleError
method eventually calls paths.logout
which properly entirely resets the application and removes the tokens.
Regarding removing the jwt
from the search params. I am not sure that we want to remove that here, since we have logic that explicitly checks for it and I am not sure if removing it will cause unwanted side effects. But if we think it is okay to remove here then I am open to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
There is bug in GenAI currently where a user gets stuck in an infinite redirect loop, this fixes the issue.
You can see the bug in action below:
https://github.com/determined-ai/determined/assets/103522725/7375fff4-bdc6-4c78-a6f0-5717080cf21f
The ultimate cause of the bug is that if you look at the logic in the sign in page we:
However the issue is that in (1) the
isAuthenticated
can be set to true without the user actually being a valid and authenticated user. This causes an infinite login bug in GenAI since we use theMLDE
login page for authentication also. The reason that this is not an issue in MLDE is because after sign-in:dashboard
pageHowever (2) cannot happen in GenAI since the invalid token lives and is controlled on the
MLDE
app.In order to preserve all current log in and auth related behavior, this PR introduces an extra check to ensure the user is authenticated if an
auth-token
is present. If not, then we handle the error using outhandleError
function. This set up ensures that unauthenticated users will not be improperly redirected.Test Plan
global/auth-token
?redirect
query to the login url such aslogin?redirect=/lore/
Commentary (optional)
Checklist
docs/release-notes/
.See Release Note for details.
Ticket