diff --git a/introspection_request_handler.go b/introspection_request_handler.go index b8897579..05acc6fc 100644 --- a/introspection_request_handler.go +++ b/introspection_request_handler.go @@ -127,32 +127,32 @@ func (f *Fosite) NewIntrospectionRequest(ctx context.Context, r *http.Request, s } if _, err := f.IntrospectToken(ctx, clientToken, AccessToken, session.Clone()); err != nil { - return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing.WithDebug(malformed or credentials used are invalid")) + return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing, malformed, or credentials used are invalid")) } } else { id, secret, ok := r.BasicAuth() if !ok { - return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing.WithDebug(malformed or credentials used are invalid")) + return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing")) } clientID, err := url.QueryUnescape(id) if err != nil { - return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing.WithDebug(malformed or credentials used are invalid")) + return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("Unable to decode OAuth 2.0 Client ID from HTTP basic authorization header")) } clientSecret, err := url.QueryUnescape(secret) if err != nil { - return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing.WithDebug(malformed or credentials used are invalid")) + return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("Unable to decode OAuth 2.0 Client Secret from HTTP basic authorization header")) } client, err := f.Store.GetClient(ctx, clientID) if err != nil { - return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing.WithDebug(malformed or credentials used are invalid")) + return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("Unable to find OAuth 2.0 Client from HTTP basic authorization header")) } // Enforce client authentication if err := f.Hasher.Compare(client.GetHashedSecret(), []byte(clientSecret)); err != nil { - return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("HTTP Authorization header missing.WithDebug(malformed or credentials used are invalid")) + return &IntrospectionResponse{Active: false}, errors.WithStack(ErrRequestUnauthorized.WithDebug("OAuth 2.0 Client credentials are invalid")) } } diff --git a/introspection_response_writer.go b/introspection_response_writer.go index 4dc63ce7..21290429 100644 --- a/introspection_response_writer.go +++ b/introspection_response_writer.go @@ -55,8 +55,8 @@ func (f *Fosite) WriteIntrospectionError(rw http.ResponseWriter, err error) { return } - switch errors.Cause(err) { - case ErrInvalidRequest, ErrRequestUnauthorized: + switch errors.Cause(err).Error() { + case ErrInvalidRequest.Error(), ErrRequestUnauthorized.Error(): f.writeJsonError(rw, err) return }