public class OAuth2Module extends Object
OAuth2 authorization module that provide authorization based on an access token included in the request.
The module uses AccessTokenValidators to perform the actual validation of access tokens and retrieve user profile information as a method of providing a layer of abstraction so the module can work with many different OAuth2 Providers.
Note: the individual AccessTokenValidators may required their own configuration.
Modifier and Type | Field and Description |
---|---|
static String |
OAUTH2_PROFILE_INFO_CONTEXT_KEY
Key for the Authorization Context for the profile information for the OAuth2 Access Token used to authorize
the request.
|
Constructor and Description |
---|
OAuth2Module(OAuth2AccessTokenValidator accessTokenValidator,
Set<String> requiredScopes,
boolean cacheEnabled,
int cacheSize)
Creates a new
OAuth2Module instance with the provided configuration. |
Modifier and Type | Method and Description |
---|---|
Promise<AuthorizationResult,AuthorizationException> |
authorize(String accessToken,
AuthorizationContext context)
Determines whether a request is authorized to access the resource based on the validity of an access token
the scopes of the access token.
|
public static final String OAUTH2_PROFILE_INFO_CONTEXT_KEY
public OAuth2Module(OAuth2AccessTokenValidator accessTokenValidator, Set<String> requiredScopes, boolean cacheEnabled, int cacheSize)
OAuth2Module
instance with the provided configuration.accessTokenValidator
- A OAuth2AccessTokenValidator
instance.requiredScopes
- The required OAuth2 scopes for the request to be authorized.cacheEnabled
- true
if the cache should be used.cacheSize
- The size of the cache. Only used if cacheEnabled
is set topublic Promise<AuthorizationResult,AuthorizationException> authorize(String accessToken, AuthorizationContext context)
accessToken
- context
- AuthorizationException
Copyright © 2025 Open Identity Platform Community. All rights reserved.