Merge pull request #8907 from airadier/handle-error-on-oidc-callback

Handle error on OIDC callback
This commit is contained in:
Daniel Jiang 2019-09-02 13:36:11 +08:00 committed by GitHub
commit 1a57f67413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)