Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Special logic for L5 oauth #60

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/auth/auth_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,16 @@ func GetOauth2Config(options config.OAuthOptions) (oauth2.Config, error) {
},
}, nil
}

func GetL5Oauth2Config(mainConfig *oauth2.Config) oauth2.Config {
return oauth2.Config{
RedirectURL: "https://flyte-rs.av.lyft.net/callback",
ClientID: mainConfig.ClientID,
ClientSecret: mainConfig.ClientSecret,
Scopes: []string{OidcScope, OfflineAccessType, ProfileScope},
Endpoint: oauth2.Endpoint{
AuthURL: mainConfig.Endpoint.AuthURL,
TokenURL: mainConfig.Endpoint.TokenURL,
},
}
}
5 changes: 5 additions & 0 deletions pkg/auth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func RefreshTokensIfExists(ctx context.Context, authContext interfaces.Authentic
}

func GetLoginHandler(ctx context.Context, authContext interfaces.AuthenticationContext) http.HandlerFunc {
l5OauthConfig := GetL5Oauth2Config(authContext.OAuth2Config())
return func(writer http.ResponseWriter, request *http.Request) {
csrfCookie := NewCsrfCookie()
csrfToken := csrfCookie.Value
Expand All @@ -81,6 +82,10 @@ func GetLoginHandler(ctx context.Context, authContext interfaces.AuthenticationC
redirectCookie := NewRedirectCookie(ctx, flowEndRedirectURL)
if redirectCookie != nil {
http.SetCookie(writer, redirectCookie)
// Special hack for L5 to last til the end of Q1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

if flowEndRedirectURL == "https://flyte-rs.av.lyft.net/console" {
url = l5OauthConfig.AuthCodeURL(state)
}
} else {
logger.Errorf(ctx, "Was not able to create a redirect cookie")
}
Expand Down