Add RFC 6750 WWW-Authenticate on OAuth bearer APIs
Introduce BearerChallengeMiddleware on MCP, Console and Connect GraphQL, Files, and OAuth2 userinfo. Call sites record challenge intent in context via NoteUnauthenticated, NoteInvalidToken, and NoteInsufficientScope; the middleware applies resource_metadata, invalid_token, and insufficient_scope on WriteHeader. OAuth2 access token middleware flags rejected Bearer tokens for invalid_token challenges. Add Authorizer.ScopesForAction for the scope auth-param. Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -118,7 +118,12 @@ func (a *Authorizer) checkOAuth2Scope(
|
||||
}
|
||||
|
||||
if a.scopeRegistry == nil || !a.scopeRegistry.Allows(accessToken.Scopes, action) {
|
||||
return NewInsufficientOAuth2ScopeError(principal, action)
|
||||
var scopes []coredata.OAuth2Scope
|
||||
if a.scopeRegistry != nil {
|
||||
scopes = a.scopeRegistry.ScopesForAction(action)
|
||||
}
|
||||
|
||||
return NewInsufficientOAuth2ScopeError(principal, scopes...)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user