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

Commit

Permalink
OAuth workaround for L5 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
wild-endeavor committed Feb 3, 2020
1 parent d3e4ec4 commit 5014bba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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
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

0 comments on commit 5014bba

Please sign in to comment.