Skip to content
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

Merged
merged 3 commits into from
Oct 22, 2018
Merged

Add error response if consent or login challenge is expired #1098

merged 3 commits into from
Oct 22, 2018

Conversation

konstlepa
Copy link
Contributor

Hello,

The PR fixes #1056.

Thanks

Kostya Lepa added 2 commits October 16, 2018 12:30
Signed-off-by: Kostya Lepa <const.lepa@gmail.com>
Signed-off-by: Kostya Lepa <const.lepa@gmail.com>
Copy link
Member

@aeneasr aeneasr left a 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:

  1. Please add tests:
    1. manager_test.go would be a good place to check if WasUsed is set properly
    2. 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.
  2. 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 in HandleConsent/LoginRequest for the LoginRequest/ConsentRequest struct.

// 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)
Copy link
Member

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").

Copy link
Contributor Author

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

// 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)
Copy link
Member

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>
@konstlepa konstlepa changed the title Add error response if consent or login challenge is expired (SQL only) Add error response if consent or login challenge is expired Oct 18, 2018
@konstlepa
Copy link
Contributor Author

Done

@aeneasr
Copy link
Member

aeneasr commented Oct 22, 2018

Thank you, sir!

@aeneasr aeneasr merged commit bbc4020 into ory:master Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consent: Send error response if consent or login challenge is expired or invalid
2 participants