Add handling of invalid login challenge

pull/1/head
Jan Dittberner 10 months ago
parent 0b59ad9fd4
commit b0daaf956f

@ -109,11 +109,24 @@ func (h *LoginHandler) handleGet(
) {
loginRequest, err := h.adminClient.GetLoginRequest(admin.NewGetLoginRequestParams().WithLoginChallenge(challenge))
if err != nil {
h.logger.Warnf("could not get login request for challenge %s: %v", challenge, err)
h.logger.WithError(err).WithField(
"challenge", challenge,
).Warn("could not get login request for challenge")
var e *admin.GetLoginRequestGone
if errors.As(err, &e) {
w.Header().Set("Location", *e.GetPayload().RedirectTo)
var notFound *admin.GetLoginRequestNotFound
if errors.As(err, &notFound) {
w.WriteHeader(http.StatusNotFound)
http.Error(w, notFound.GetPayload().ErrorDescription, http.StatusNotFound)
return
}
var gone *admin.GetLoginRequestGone
if errors.As(err, &gone) {
w.Header().Set("Location", *gone.GetPayload().RedirectTo)
w.WriteHeader(http.StatusGone)
return

Loading…
Cancel
Save