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(Customizer) - enables Jwt-encoded bearer token supportopaqueToken(Customizer) - enables opaque bearer token support
When using jwt(Customizer), either
OAuth2ResourceServerConfigurer.JwtConfigurer.jwkSetUri(java.lang.String), orJwtDecoder instance via OAuth2ResourceServerConfigurer.JwtConfigurer.decoder, orJwtDecoder beanjwt(Customizer) consider
Jwt to an
Authentication with
OAuth2ResourceServerConfigurer.JwtConfigurer.jwtAuthenticationConverter(Converter)
When using opaqueToken(Customizer), supply an introspection endpoint and its
authentication configuration
Filters are populated when jwt(Customizer) is
configured:
BearerTokenAuthenticationFilterSessionCreationPolicy (optional)AuthenticationManagerBearerTokenAuthenticationFilter,
JwtAuthenticationProvider,
NimbusJwtDecoder,
AbstractHttpConfigurer| Modifier and Type | Class and Description |
|---|---|
class |
OAuth2ResourceServerConfigurer.JwtConfigurer |
class |
OAuth2ResourceServerConfigurer.OpaqueTokenConfigurer |
| 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> |
authenticationManagerResolver(org.springframework.security.authentication.AuthenticationManagerResolver<javax.servlet.http.HttpServletRequest> authenticationManagerResolver) |
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() |
OAuth2ResourceServerConfigurer<H> |
jwt(Customizer<OAuth2ResourceServerConfigurer.JwtConfigurer> jwtCustomizer)
Enables Jwt-encoded bearer token support.
|
OAuth2ResourceServerConfigurer.OpaqueTokenConfigurer |
opaqueToken() |
OAuth2ResourceServerConfigurer<H> |
opaqueToken(Customizer<OAuth2ResourceServerConfigurer.OpaqueTokenConfigurer> opaqueTokenCustomizer)
Enables opaque bearer token support.
|
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> authenticationManagerResolver(org.springframework.security.authentication.AuthenticationManagerResolver<javax.servlet.http.HttpServletRequest> authenticationManagerResolver)
public OAuth2ResourceServerConfigurer<H> bearerTokenResolver(org.springframework.security.oauth2.server.resource.web.BearerTokenResolver bearerTokenResolver)
public OAuth2ResourceServerConfigurer.JwtConfigurer jwt()
public OAuth2ResourceServerConfigurer<H> jwt(Customizer<OAuth2ResourceServerConfigurer.JwtConfigurer> jwtCustomizer)
jwtCustomizer - the Customizer to provide more options for the
OAuth2ResourceServerConfigurer.JwtConfigurerOAuth2ResourceServerConfigurer for further customizationspublic OAuth2ResourceServerConfigurer.OpaqueTokenConfigurer opaqueToken()
public OAuth2ResourceServerConfigurer<H> opaqueToken(Customizer<OAuth2ResourceServerConfigurer.OpaqueTokenConfigurer> opaqueTokenCustomizer)
opaqueTokenCustomizer - the Customizer to provide more options for the
OAuth2ResourceServerConfigurer.OpaqueTokenConfigurerOAuth2ResourceServerConfigurer for further customizationspublic void init(H http)
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. Configurers should be applied here.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>>public void configure(H http)
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>>