Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions introspection_request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}

Expand Down
4 changes: 2 additions & 2 deletions introspection_response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down