mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-11 02:17:42 +01:00
Handle error on OIDC callback
If wrong OIDC scopes are defined, or there are some configuration errors, the OIDC callback query string might contain "error=..." with an error message. Intercept this case and show an error to the user instead of trying to exchange the token with a missing "code" parameter. Signed-off-by: Iradier, AlvaroJose <AlvaroJose.Iradier@adidas.com> Change error variable name Signed-off-by: Iradier, AlvaroJose <AlvaroJose.Iradier@adidas.com>
This commit is contained in:
parent
93f86e321b
commit
bf9ac08c89
@ -83,6 +83,15 @@ func (oc *OIDCController) Callback() {
|
||||
oc.SendBadRequestError(errors.New("State mismatch"))
|
||||
return
|
||||
}
|
||||
|
||||
errorCode := oc.Ctx.Request.URL.Query().Get("error")
|
||||
if errorCode != "" {
|
||||
errorDescription := oc.Ctx.Request.URL.Query().Get("error_description")
|
||||
log.Errorf("OIDC callback returned error: %s - %s", errorCode, errorDescription)
|
||||
oc.SendBadRequestError(errors.Errorf("OIDC callback returned error: %s - %s", errorCode, errorDescription))
|
||||
return
|
||||
}
|
||||
|
||||
code := oc.Ctx.Request.URL.Query().Get("code")
|
||||
ctx := oc.Ctx.Request.Context()
|
||||
token, err := oidc.ExchangeToken(ctx, code)
|
||||
|
Loading…
Reference in New Issue
Block a user