Skip to content

Commit

Permalink
openid: Adds errors for request and registration parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
arekkas authored and arekkas committed Jun 23, 2018
1 parent edc4910 commit 920ed71
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions authorize_request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ func (c *Fosite) NewAuthorizeRequest(ctx context.Context, r *http.Request) (Auth
}
request.State = state

if len(request.Form.Get("request")) > 0 {
return request, errors.WithStack(ErrRequestNotSupported)
}

if len(request.Form.Get("request_uri")) > 0 {
return request, errors.WithStack(ErrRequestURINotSupported)
}

if len(request.Form.Get("registration")) > 0 {
return request, errors.WithStack(ErrRegistrationNotSupported)
}

// Remove empty items from arrays
request.SetRequestedScopes(scope)
return request, nil
Expand Down
18 changes: 18 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ var (
Name: errConsentRequired,
Code: http.StatusBadRequest,
}
ErrRequestNotSupported = &RFC6749Error{
Description: "The OP does not support use of the request parameter",
Name: errRequestNotSupportedName,
Code: http.StatusBadRequest,
}
ErrRequestURINotSupported = &RFC6749Error{
Description: "The OP does not support use of the request_uri parameter",
Name: errRequestURINotSupportedName,
Code: http.StatusBadRequest,
}
ErrRegistrationNotSupported = &RFC6749Error{
Description: "The OP does not support use of the registration parameter",
Name: errRegistrationNotSupportedName,
Code: http.StatusBadRequest,
}
)

const (
Expand Down Expand Up @@ -209,6 +224,9 @@ const (
errAuthorizaionCodeInactiveName = "authorization_code_inactive"
errUnknownErrorName = "error"
errRevokationClientMismatchName = "revokation_client_mismatch"
errRequestNotSupportedName = "request_not_supported"
errRequestURINotSupportedName = "request_uri_not_supported"
errRegistrationNotSupportedName = "registration_not_supported"
)

func ErrorToRFC6749Error(err error) *RFC6749Error {
Expand Down

0 comments on commit 920ed71

Please sign in to comment.