Skip to content

Commit

Permalink
Uses suggested style to discriminate PKCE case
Browse files Browse the repository at this point in the history
  • Loading branch information
skyreginag committed Oct 2, 2024
1 parent e098204 commit adcaf83
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions controller/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,18 @@ func (uc *UserController) RedirecToSericeAuth(c echo.Context) error {

logger.Debug("Doing URL for provider:", providerName)

u := ""
if config.Setting.OAUTH2_SETTINGS.UsePkce == true {
u = config.Setting.MAIN_SETTINGS.OAuth2Config.AuthCodeURL(config.Setting.OAUTH2_SETTINGS.StateValue,
oauth2.SetAuthURLParam("response_type", config.Setting.OAUTH2_SETTINGS.ResponseType),
options := []oauth2.AuthCodeOption{
oauth2.SetAuthURLParam("response_type", config.Setting.OAUTH2_SETTINGS.ResponseType),
}

if config.Setting.OAUTH2_SETTINGS.UsePkce {
options = append(options,
oauth2.SetAuthURLParam("code_challenge", heputils.GenCodeChallengeS256(config.Setting.OAUTH2_SETTINGS.UserToken)),
oauth2.SetAuthURLParam("code_challenge_method", "S256"))
} else {
u = config.Setting.MAIN_SETTINGS.OAuth2Config.AuthCodeURL(config.Setting.OAUTH2_SETTINGS.StateValue,
oauth2.SetAuthURLParam("response_type", config.Setting.OAUTH2_SETTINGS.ResponseType))
}

u := config.Setting.MAIN_SETTINGS.OAuth2Config.AuthCodeURL(config.Setting.OAUTH2_SETTINGS.StateValue, options...)

logger.Debug("RedirecToSericeAuth Redirecting URL :", u)

return c.Redirect(http.StatusFound, u)
Expand Down

0 comments on commit adcaf83

Please sign in to comment.