authenticate: add aws cognito

This commit is contained in:
Denis Mishin 2023-04-28 18:31:38 -04:00
parent 498bc82e81
commit 64323c5231
3 changed files with 78 additions and 9 deletions

View file

@ -273,20 +273,23 @@ func (a *Authenticate) signOutRedirect(w http.ResponseWriter, r *http.Request) e
}
endSessionURL, err := authenticator.LogOut()
if err == nil && redirectString != "" {
if err != nil {
if !errors.Is(err, oidc.ErrSignoutNotImplemented) {
log.Warn(r.Context()).Err(err).Msg("authenticator.LogOut")
}
return httputil.NewError(http.StatusOK, errors.New("user logged out"))
}
if redirectString != "" {
params := url.Values{}
params.Add("id_token_hint", rawIDToken)
params.Add("post_logout_redirect_uri", redirectString)
endSessionURL.RawQuery = params.Encode()
redirectString = endSessionURL.String()
} else if err != nil && !errors.Is(err, oidc.ErrSignoutNotImplemented) {
log.Warn(r.Context()).Err(err).Msg("authenticate.SignOut: failed getting session")
}
if redirectString != "" {
httputil.Redirect(w, r, redirectString, http.StatusFound)
return nil
}
return httputil.NewError(http.StatusOK, errors.New("user logged out"))
redirectString = endSessionURL.String()
httputil.Redirect(w, r, redirectString, http.StatusFound)
return nil
}
// reauthenticateOrFail starts the authenticate process by redirecting the