-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error response if consent or login challenge is expired #1098
Conversation
Signed-off-by: Kostya Lepa <const.lepa@gmail.com>
Signed-off-by: Kostya Lepa <const.lepa@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good, thank you! Two things:
- Please add tests:
manager_test.go
would be a good place to check ifWasUsed
is set properly- I know that the handler does not have any tests (other than log out right now) but it would be good to see if the GetConsentRequest/GetLoginRequest behave correctly when
WasUsed
is set. If you feel lost on how to approach it please let me know and I'll help.
- Please add this behavior to the memory manager as well. All you have to do for that is to iterate over the handled requests like here in the GetLogin/ConsentRequest methods and populate the field accordingly. Alternatively, you could set
WasUsed
inHandleConsent/LoginRequest
for theLoginRequest
/ConsentRequest
struct.
consent/handler.go
Outdated
// 500: genericError | ||
func (h *Handler) GetLoginRequest(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { | ||
request, err := h.M.GetAuthenticationRequest(r.Context(), ps.ByName("challenge")) | ||
if err != nil { | ||
h.H.WriteError(w, r, err) | ||
return | ||
} | ||
if request.WasHandled { | ||
h.H.WriteError(w, r, pkg.ErrConflict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have a descriptive error here like the one from the manager: fosite.ErrInvalidRequest.WithDebug("Authentication verifier has been used already")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll add it
consent/handler.go
Outdated
// 500: genericError | ||
func (h *Handler) GetConsentRequest(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { | ||
request, err := h.M.GetConsentRequest(r.Context(), ps.ByName("challenge")) | ||
if err != nil { | ||
h.H.WriteError(w, r, err) | ||
return | ||
} | ||
if request.WasHandled { | ||
h.H.WriteError(w, r, pkg.ErrConflict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have a descriptive error here like the one from the manager: fosite.ErrInvalidRequest.WithDebug("Consent verifier has been used already")
.
…Request/GetConsentRequest Signed-off-by: Kostya Lepa <const.lepa@gmail.com>
Done |
Thank you, sir! |
Hello,
The PR fixes #1056.
Thanks