Skip to content

Commit

Permalink
revoke_handler: respecting ErrInvalidRequest code
Browse files Browse the repository at this point in the history
This commit modifies the case for ErrInvalidRequest in
WriteRevocationResponse to respect the 400 error code
and not fallthrough to ErrInvalidClient.

Author:    DefinitelyNotAGoat <baldrich@protonmail.com>
  • Loading branch information
DefinitelyNotAGoat committed Aug 23, 2019
1 parent 54426bb commit 89c76f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion revoke_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ func (f *Fosite) WriteRevocationResponse(rw http.ResponseWriter, err error) {

switch errors.Cause(err).Error() {
case ErrInvalidRequest.Error():
fallthrough
rw.Header().Set("Content-Type", "application/json;charset=UTF-8")

js, err := json.Marshal(ErrInvalidRequest)
if err != nil {
http.Error(rw, fmt.Sprintf(`{"error": "%s"}`, err.Error()), http.StatusInternalServerError)
return
}

rw.WriteHeader(ErrInvalidRequest.Code)
rw.Write(js)
case ErrInvalidClient.Error():
rw.Header().Set("Content-Type", "application/json;charset=UTF-8")

Expand Down

0 comments on commit 89c76f2

Please sign in to comment.