Class ChenileSecurityConfiguration
java.lang.Object
org.chenile.configuration.security.ChenileSecurityConfiguration
-
Field Summary
Modifier and TypeFieldDescription(package private) String
(package private) String
(package private) KeycloakConnectionDetails
(package private) boolean
private final org.slf4j.Logger
(package private) String
(package private) String
private final Map<String,
org.springframework.security.oauth2.client.registration.ClientRegistrationRepository> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate org.springframework.security.authentication.AuthenticationManagerResolver<HttpServletRequest>
org.springframework.security.oauth2.client.OAuth2AuthorizedClientService
authorizedClientService
(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository) org.springframework.security.oauth2.client.registration.ClientRegistration
client()
org.springframework.security.oauth2.client.registration.ClientRegistration
org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
private org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
clientRegistrationRepository
(String tenantId) private org.springframework.security.authentication.AuthenticationManager
getAuthenticationManager
(String tenantId) Here we take the tenant ID to construct a specific URL (with the realm as tenant ID) and return an Authentication Manager for that realm.private org.springframework.security.authentication.AuthenticationManager
private Converter<org.springframework.security.oauth2.jwt.Jwt,
? extends org.springframework.security.authentication.AbstractAuthenticationToken> (package private) org.springframework.security.oauth2.jwt.JwtDecoder
jwtDecoder
(String tenantId) private String
keycloakBaseUrl
(String realm) private String
keycloakOpenIdUrl
(String realm) private org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver
resolver()
org.springframework.security.web.SecurityFilterChain
securityFilterChain
(org.springframework.security.config.annotation.web.builders.HttpSecurity http) (package private) SecurityService
-
Field Details
-
logger
private final org.slf4j.Logger logger -
connectionDetails
-
clientId
-
clientSecret
-
loginSuccessUrl
-
loginFailureUrl
-
ignoreSecurity
-
repositories
-
authenticationManagers
-
jwtDecoderMap
-
-
Constructor Details
-
ChenileSecurityConfiguration
public ChenileSecurityConfiguration()
-
-
Method Details
-
securityFilterChain
@Bean public org.springframework.security.web.SecurityFilterChain securityFilterChain(org.springframework.security.config.annotation.web.builders.HttpSecurity http) throws Exception - Throws:
Exception
-
resolver
private org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver resolver() -
clientRegistrationRepository
@Bean public org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository() -
clientRegistrationRepository
private org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository(String tenantId) -
authorizedClientService
@Bean public org.springframework.security.oauth2.client.OAuth2AuthorizedClientService authorizedClientService(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository) -
client
public org.springframework.security.oauth2.client.registration.ClientRegistration client() -
client
-
authenticationManagerResolver
private org.springframework.security.authentication.AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver() -
getAuthenticationManager
private org.springframework.security.authentication.AuthenticationManager getAuthenticationManager(String tenantId) Here we take the tenant ID to construct a specific URL (with the realm as tenant ID) and return an Authentication Manager for that realm.
Since the URL that is constructed depends on the validity of the tenant ID, it is possible that we may get a 404 from keycloak. To take care of this, we will recast all exceptions to "InvalidBearerTokenException" so that spring security will give a 401 in all those cases.- Parameters:
tenantId
- the tenant ID- Returns:
- the Authentication manager for the particular tenant ID
-
jwt
-
jwtBearerTokenAuthenticationConverter
private Converter<org.springframework.security.oauth2.jwt.Jwt,? extends org.springframework.security.authentication.AbstractAuthenticationToken> jwtBearerTokenAuthenticationConverter() -
keycloakBaseUrl
-
keycloakOpenIdUrl
-
jwtDecoder
-
securityService
-