public final class OAuth2ResourceServerConfigurer<H extends HttpSecurityBuilder<H>> extends AbstractHttpConfigurer<OAuth2ResourceServerConfigurer<H>,H>
AbstractHttpConfigurer for OAuth 2.0 Resource Server Support.
By default, this wires a BearerTokenAuthenticationFilter, which can be used to parse the request
for bearer tokens and make an authentication attempt.
The following configuration options are available:
accessDeniedHandler(AccessDeniedHandler)authenticationEntryPoint(AuthenticationEntryPoint)bearerTokenResolver(BearerTokenResolver) - customizes how to resolve a bearer token from the requestjwt() - enables Jwt-encoded bearer token support
When using jwt(), either
OAuth2ResourceServerConfigurer.JwtConfigurer.jwkSetUri(java.lang.String), or
JwtDecoder instance via OAuth2ResourceServerConfigurer.JwtConfigurer.decoder, or
JwtDecoder bean
jwt() consider
Jwt to an Authentication with
OAuth2ResourceServerConfigurer.JwtConfigurer.jwtAuthenticationConverter(Converter)
Filters are populated when jwt() is configured:
BearerTokenAuthenticationFilterSessionCreationPolicy (optional)AuthenticationManagerBearerTokenAuthenticationFilter,
JwtAuthenticationProvider,
NimbusJwtDecoderJwkSupport,
AbstractHttpConfigurer| Modifier and Type | Class and Description |
|---|---|
class |
OAuth2ResourceServerConfigurer.JwtConfigurer |
| Constructor and Description |
|---|
OAuth2ResourceServerConfigurer(org.springframework.context.ApplicationContext context) |
| Modifier and Type | Method and Description |
|---|---|
OAuth2ResourceServerConfigurer<H> |
accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler accessDeniedHandler) |
OAuth2ResourceServerConfigurer<H> |
authenticationEntryPoint(org.springframework.security.web.AuthenticationEntryPoint entryPoint) |
OAuth2ResourceServerConfigurer<H> |
bearerTokenResolver(org.springframework.security.oauth2.server.resource.web.BearerTokenResolver bearerTokenResolver) |
void |
configure(H http)
Configure the
SecurityBuilder by setting the necessary properties on the
SecurityBuilder. |
void |
init(H http)
Initialize the
SecurityBuilder. |
OAuth2ResourceServerConfigurer.JwtConfigurer |
jwt() |
disable, withObjectPostProcessoraddObjectPostProcessor, and, getBuilder, postProcess, setBuilderpublic OAuth2ResourceServerConfigurer(org.springframework.context.ApplicationContext context)
public OAuth2ResourceServerConfigurer<H> accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler accessDeniedHandler)
public OAuth2ResourceServerConfigurer<H> authenticationEntryPoint(org.springframework.security.web.AuthenticationEntryPoint entryPoint)
public OAuth2ResourceServerConfigurer<H> bearerTokenResolver(org.springframework.security.oauth2.server.resource.web.BearerTokenResolver bearerTokenResolver)
public OAuth2ResourceServerConfigurer.JwtConfigurer jwt()
public void init(H http) throws java.lang.Exception
SecurityConfigurerSecurityBuilder. Here only shared state should be created
and modified, but not properties on the SecurityBuilder used for building
the object. This ensures that the SecurityConfigurer.configure(SecurityBuilder) method uses
the correct shared objects when building.init in interface SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>init in class SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>java.lang.Exceptionpublic void configure(H http) throws java.lang.Exception
SecurityConfigurerSecurityBuilder by setting the necessary properties on the
SecurityBuilder.configure in interface SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>configure in class SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>java.lang.Exception