-
Notifications
You must be signed in to change notification settings - Fork 45
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
Update token endpoint for better error handling #364
Conversation
95ac2e6
to
f0d0568
Compare
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
web/auth.go
Outdated
// - return an unauthenticated error 401 | ||
// - force user logout | ||
if failedToGetCookies && current != "" { | ||
isValid := h.state.sessions.HasSessionWithAccessToken(ctx, current) |
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.
@jr22 Ok so when testing, I noticed I could logout, and use my old token from the logged out session to get myself a new token and start an active session. Just want to check, I would assume if the value of current
is a token that was logged out, then this would return false
, but it appears that may not be happening given my testing on @mcous 's PR. Is my assumption correct?
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.
hm yeah i wouldnt think that should work. let me know if you want to debug together.
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.
did you fix this/ figure out what was going on?
@jr22 I have been fighting this linter for way too long. For some reason, I can't run WARN [linters_context] running gomodguard failed: unable to parse module file go.mod: go.mod:3: invalid go version '1.21.13': must match format 1.23: if you are not using go modules it is suggested to disable this linter
WARN [linters_context] running gomoddirectives failed: failed to get module file: go.mod:3: invalid go version '1.21.13': must match format 1.23: if you are not using go modules it is suggested to disable this linter It seems to run fine in CI. I just wiped my local repo, re-cloned, and tried again, and I am seeing the same issues. There are linting issues, but I can't parse what the problem is. |
might be because the |
Ah that makes sense, thanks. |
@mcous updated the code per our last conversation, should we link it on your PR so we can test it out? |
@jr22 @mcous Got tests passing on the app PR: https://github.com/viamrobotics/app/pull/6392 I think we are good to final review and merge this, cut a release, and then merge that app-side PR. |
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.
See smoke testing results at: https://github.com/viamrobotics/app/pull/6392#pullrequestreview-2429958898
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.
2 small comments (not blocking) otherwise looks good
defer span.End() | ||
|
||
current := getBearerToken(r) | ||
data := getAndClearAuthCookieValues(w, r) |
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.
note that theres a small change in behavior here where we will still clear cookies even if the json marshling fails. i think this is fine but calling it out
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.
Good callout. I agree it's fine, if the marshalling fails it probably means something was broken/corrupted in the auth flow and it is probably best to start again with a clean state.
Update the token endpoint to read the existing bearer token (if it exists) and better handle situations a user may run into.
Otherwise, we will continue with the existing behavior.
Left comments in to explain the flow, can delete/simplify them before merging.