From dfb129a5b7c8ae01e1c490fce1a127697abc7bee Mon Sep 17 00:00:00 2001 From: Damian Peckett Date: Thu, 3 Aug 2023 12:24:14 +0200 Subject: [PATCH] fix: restore ability to override auth and token urls for exemplary app (#3590) --- cmd/cmd_perform_authorization_code.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/cmd_perform_authorization_code.go b/cmd/cmd_perform_authorization_code.go index 60c0ae57425..67cbea752a9 100644 --- a/cmd/cmd_perform_authorization_code.go +++ b/cmd/cmd_perform_authorization_code.go @@ -97,6 +97,8 @@ and success, unless if the --no-shutdown flag is provided.`, prompt := flagx.MustGetStringSlice(cmd, "prompt") maxAge := flagx.MustGetInt(cmd, "max-age") redirectUrl := flagx.MustGetString(cmd, "redirect") + authUrl := flagx.MustGetString(cmd, "auth-url") + tokenUrl := flagx.MustGetString(cmd, "token-url") audience := flagx.MustGetStringSlice(cmd, "audience") noShutdown := flagx.MustGetBool(cmd, "no-shutdown") @@ -118,15 +120,20 @@ and success, unless if the --no-shutdown flag is provided.`, redirectUrl = serverLocation + "callback" } - if err != nil { - return err + if authUrl == "" { + authUrl = urlx.AppendPaths(endpoint, "/oauth2/auth").String() } + + if tokenUrl == "" { + tokenUrl = urlx.AppendPaths(endpoint, "/oauth2/token").String() + } + conf := oauth2.Config{ ClientID: clientID, ClientSecret: clientSecret, Endpoint: oauth2.Endpoint{ - TokenURL: urlx.AppendPaths(endpoint, "/oauth2/token").String(), - AuthURL: urlx.AppendPaths(endpoint, "/oauth2/auth").String(), + AuthURL: authUrl, + TokenURL: tokenUrl, }, RedirectURL: redirectUrl, Scopes: scopes,