-
Notifications
You must be signed in to change notification settings - Fork 46
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
APP-3031: make auth0.go generic to auth providers #216
Conversation
Bringing in the council of Michaels on this one |
One thing I'm not clear on is whether I broke the automatic call to |
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, some naming suggestions.
@@ -23,30 +23,43 @@ import ( | |||
"go.viam.com/utils" | |||
) | |||
|
|||
// Auth0Config config for auth0. | |||
type Auth0Config struct { | |||
// AuthProviderConfig config options with constants that will probably need to be manually configured after |
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] consider renaming this file to oidc.go
?
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.
I didn't want to rename as part of this PR as it would destroy the commit history on the squash and merge. I think I should do a git mv
as a follow up
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.
Fine with me!
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
As long as the app side still calls Close() like it does here: https://github.com/viamrobotics/app/blob/main/server/server.go#L1691, then I don't think there is anything to be concerned about. Its just refactoring and the Close call will be the same. |
Finally gearing up to merge this since we moved forward the testing and doesn't look like we'll need more app changes? |
Dismissing due to ongoing changes, will re-review when ready
web/auth0.go
Outdated
// http.SetCookie(w, &http.Cookie{ | ||
// Name: h.redirectStateCookieName, | ||
// Value: "", | ||
// Path: "/", | ||
// MaxAge: -1, | ||
// Secure: r.TLS != nil, | ||
// SameSite: http.SameSiteLaxMode, | ||
// HttpOnly: true, | ||
// }) |
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.
[q] @DTCurrie, so this should be turned off for FusionAuth only? Or for both Auth0 and FusionAuth?
http.SetCookie(w, &http.Cookie{ | ||
Name: "viam.auth.token", | ||
Value: token.AccessToken, | ||
Path: "/", | ||
Expires: token.Expiry, | ||
Secure: r.TLS != nil, | ||
SameSite: http.SameSiteLaxMode, | ||
HttpOnly: true, | ||
}) | ||
|
||
http.SetCookie(w, &http.Cookie{ | ||
Name: "viam.auth.refresh", | ||
Value: token.RefreshToken, | ||
Path: "/", | ||
Expires: token.Expiry, | ||
Secure: r.TLS != nil, | ||
SameSite: http.SameSiteLaxMode, | ||
HttpOnly: true, | ||
}) | ||
|
||
http.SetCookie(w, &http.Cookie{ | ||
Name: "viam.auth.expiry", | ||
Value: token.Expiry.Format(time.RFC3339), | ||
Path: "/", | ||
Expires: token.Expiry, | ||
Secure: r.TLS != nil, | ||
SameSite: http.SameSiteLaxMode, | ||
HttpOnly: true, | ||
}) |
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.
@DTCurrie same here -- is there any harm in this being sent for Auth0 as well as FusionAuth? Trying to split this out into different auth providers.
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.
I didn’t actually comment out that first cookie originally, but so don’t think there is any harm in uncommenting it our now. It shouldn’t interfere with what I added.
The changes I made in app don’t really care about auth0 or fusion auth, so the added logic should conceivably work for both. Basically we set temporary cookies with the access token and it’s expiry, then on the front end we call the new token endpoint I added to return those values and clear the temp cookies. Then the front end caches those in local storage and uses them from there. If the expiry time has passed, it sends the user to log back in.
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 the lightning fast response!
APP-3031
(app PR that incorporates these changes)
Tiny PR that I believe (🤞) includes all the changes needed to
auth0.go
to make it so that we can cutover theapp
backend to FusionAuth without any furthergoutils
changes.I didn't rename
auth0.go
because it'll destroy the version history on this file if I do a squash and merge (only thing enabled for our repo afaik).Tested that auth still works in
app
if I:0) [local setup] add
replace go.viam.com/utils => ../goutils
and thengo mod tidy
server/server.go
and
I'll update
goutils
in app with the changes above once this is ready to merge.