@Configuration @ConditionalOnBean(value=org.springframework.security.authentication.AuthenticationManager.class) public class GrpcSecurityAutoConfiguration extends Object
To enable security add both an AuthenticationManager
and a GrpcAuthenticationReader
to the
application context. The authentication reader obtains the credentials from the requests which then will be validated
by the authentication manager. After that, you can decide how you want to secure your application. Currently these
options are available:
@EnableGlobalMethodSecurity(proxyTargetClass = true, ...)
.AccessDecisionManager
and a GrpcSecurityMetadataSource
in the application context.
Note: The order of the beans is important! First the authorization checking interceptor, then the authenticating interceptor and finally the exception translating interceptor. That is necessary because they are executed in the reverse order of being declared.
Constructor and Description |
---|
GrpcSecurityAutoConfiguration() |
Modifier and Type | Method and Description |
---|---|
AuthenticatingServerInterceptor |
authenticatingServerInterceptor(AuthenticationManager authenticationManager,
GrpcAuthenticationReader authenticationReader) |
AuthorizationCheckingServerInterceptor |
authorizationCheckingServerInterceptor(AccessDecisionManager accessDecisionManager,
GrpcSecurityMetadataSource securityMetadataSource) |
ExceptionTranslatingServerInterceptor |
exceptionTranslatingServerInterceptor() |
@Bean @ConditionalOnMissingBean @ConditionalOnBean(value={org.springframework.security.access.AccessDecisionManager.class,GrpcSecurityMetadataSource.class}) public AuthorizationCheckingServerInterceptor authorizationCheckingServerInterceptor(AccessDecisionManager accessDecisionManager, GrpcSecurityMetadataSource securityMetadataSource)
@Bean @ConditionalOnMissingBean public AuthenticatingServerInterceptor authenticatingServerInterceptor(AuthenticationManager authenticationManager, GrpcAuthenticationReader authenticationReader)
@Bean @ConditionalOnMissingBean public ExceptionTranslatingServerInterceptor exceptionTranslatingServerInterceptor()