@Configuration @ComponentScan(basePackageClasses=AbstractExceptionHandler.class) @EnableTransactionManagement @EnableJpaAuditing @EnableAsync @EnableGlobalMethodSecurity(prePostEnabled=true) @AutoConfigureBefore(value={org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.class,org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration.class,org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration.class}) public class LemonAutoConfiguration extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JSON_PREFIX
For handling JSON vulnerability,
JSON response bodies would be prefixed with
this string.
|
Constructor and Description |
---|
LemonAutoConfiguration() |
Modifier and Type | Method and Description |
---|---|
<U extends AbstractUser<U,ID>,ID extends java.io.Serializable> |
auditorAware(AbstractUserRepository<U,ID> userRepository)
Configures an Auditor Aware if missing
|
org.springframework.security.web.authentication.AuthenticationFailureHandler |
authenticationFailureHandler()
Configures AuthenticationFailureHandler if missing
|
AuthenticationSuccessHandler |
authenticationSuccessHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
JwtService jwtService,
LemonProperties properties)
Configures AuthenticationSuccessHandler if missing
|
CaptchaValidator |
captchaValidator(LemonProperties properties,
org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder)
Configures CaptchaValidator if missing
|
<T extends java.lang.Throwable> |
defaultExceptionHandlerControllerAdvice(ErrorResponseComposer<T> errorResponseComposer)
Configures DefaultExceptionHandlerControllerAdvice if missing
|
<T extends java.lang.Throwable> |
errorAttributes(ErrorResponseComposer<T> errorResponseComposer)
Configures an Error Attributes if missing
|
org.springframework.boot.web.servlet.error.ErrorController |
errorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes,
org.springframework.boot.autoconfigure.web.ServerProperties serverProperties,
java.util.List<org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver> errorViewResolvers)
Configures an Error Controller if missing
|
<T extends java.lang.Throwable> |
errorResponseComposer(java.util.List<AbstractExceptionHandler<T>> handlers)
Configures ErrorResponseComposer if missing
|
<U extends AbstractUser<U,ID>,ID extends java.io.Serializable> |
jwtAuthenticationProvider(JwtService jwtService,
LemonUserDetailsService<U,ID> userDetailsService)
Configures JwtAuthenticationProvider if missing
|
JwtService |
jwtService(LemonProperties properties)
Configures JwtService if missing
|
LemonCorsConfig |
lemonCorsConfig(LemonProperties properties)
Configures LemonCorsConfig if missing and lemon.cors.allowed-origins is provided
|
<U extends AbstractUser<U,ID>,ID extends java.io.Serializable> |
lemonOAuth2UserService(LemonUserDetailsService<U,?> userDetailsService,
LemonService<U,?> lemonService,
org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
Configures LemonOAuth2UserService if missing
|
LemonOidcUserService |
lemonOidcUserService(LemonOAuth2UserService<?,?> lemonOAuth2UserService)
Configures LemonOidcUserService if missing
|
LemonProperties |
lemonProperties()
Spring Lemon related properties
|
LemonSecurityConfig |
lemonSecurityConfig()
Configures LemonSecurityConfig if missing
|
LemonTokenAuthenticationFilter |
lemonTokenAuthenticationFilter(LemonSecurityConfig lemonSecurityConfig)
Configures our TokenAuthenticationFilter
|
LemonUtils |
lemonUtil(org.springframework.context.ApplicationContext applicationContext,
org.springframework.context.MessageSource messageSource,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Configures LemonUtils
|
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter |
mappingJackson2HttpMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Prefixes JSON responses for JSON vulnerability.
|
MailSender<?> |
mockMailSender()
Configures a MockMailSender when the property
spring.mail.host isn't defined. |
OAuth2AuthenticationFailureHandler |
oAuth2AuthenticationFailureHandler()
Configures OAuth2AuthenticationFailureHandler if missing
|
OAuth2AuthenticationSuccessHandler<?> |
oauth2AuthenticationSuccessHandler(LemonProperties properties,
JwtService jwtService)
Configures OAuth2AuthenticationSuccessHandler if missing
|
org.springframework.security.crypto.password.PasswordEncoder |
passwordEncoder()
Configures Password encoder if missing
|
org.springframework.security.access.PermissionEvaluator |
permissionEvaluator()
Configures PermissionEvaluator if missing
|
RetypePasswordValidator |
retypePasswordValidator()
Configures RetypePasswordValidator if missing
|
MailSender<?> |
smtpMailSender(org.springframework.mail.javamail.JavaMailSender javaMailSender)
Configures an SmtpMailSender when the property
spring.mail.host is defined. |
UniqueEmailValidator |
uniqueEmailValidator(AbstractUserRepository<?,?> userRepository)
Configures UniqueEmailValidator if missing
|
<U extends AbstractUser<U,ID>,ID extends java.io.Serializable> |
userDetailService(AbstractUserRepository<U,ID> userRepository)
Configures UserDetailsService if missing
|
public static final java.lang.String JSON_PREFIX
@Bean @ConditionalOnProperty(name="lemon.enabled.json-prefix") public org.springframework.http.converter.json.MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
@Bean @ConditionalOnMissingBean(value=org.springframework.security.crypto.password.PasswordEncoder.class) public org.springframework.security.crypto.password.PasswordEncoder passwordEncoder()
@Bean public LemonProperties lemonProperties()
@Bean @ConditionalOnMissingBean(value=org.springframework.data.domain.AuditorAware.class) public <U extends AbstractUser<U,ID>,ID extends java.io.Serializable> org.springframework.data.domain.AuditorAware<U> auditorAware(AbstractUserRepository<U,ID> userRepository)
@Bean @ConditionalOnMissingBean(value=ErrorResponseComposer.class) public <T extends java.lang.Throwable> ErrorResponseComposer<T> errorResponseComposer(java.util.List<AbstractExceptionHandler<T>> handlers)
@Bean @ConditionalOnMissingBean(value=DefaultExceptionHandlerControllerAdvice.class) public <T extends java.lang.Throwable> DefaultExceptionHandlerControllerAdvice<T> defaultExceptionHandlerControllerAdvice(ErrorResponseComposer<T> errorResponseComposer)
@Bean @ConditionalOnMissingBean(value=org.springframework.boot.web.servlet.error.ErrorAttributes.class) public <T extends java.lang.Throwable> org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes(ErrorResponseComposer<T> errorResponseComposer)
@Bean @ConditionalOnMissingBean(value=org.springframework.boot.web.servlet.error.ErrorController.class) public org.springframework.boot.web.servlet.error.ErrorController errorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, org.springframework.boot.autoconfigure.web.ServerProperties serverProperties, java.util.List<org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver> errorViewResolvers)
@Bean @ConditionalOnMissingBean(value=MailSender.class) @ConditionalOnProperty(name="spring.mail.host", havingValue="foo", matchIfMissing=true) public MailSender<?> mockMailSender()
spring.mail.host
isn't defined.@Bean @ConditionalOnMissingBean(value=MailSender.class) @ConditionalOnProperty(value="spring.mail.host") public MailSender<?> smtpMailSender(org.springframework.mail.javamail.JavaMailSender javaMailSender)
spring.mail.host
is defined.@Bean @ConditionalOnMissingBean(value=JwtService.class) public JwtService jwtService(LemonProperties properties) throws com.nimbusds.jose.KeyLengthException
com.nimbusds.jose.KeyLengthException
@Bean @ConditionalOnMissingBean(value=AuthenticationSuccessHandler.class) public AuthenticationSuccessHandler authenticationSuccessHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper, JwtService jwtService, LemonProperties properties)
@Bean @ConditionalOnMissingBean(value=OAuth2AuthenticationSuccessHandler.class) public OAuth2AuthenticationSuccessHandler<?> oauth2AuthenticationSuccessHandler(LemonProperties properties, JwtService jwtService)
@Bean @ConditionalOnMissingBean(value=OAuth2AuthenticationFailureHandler.class) public OAuth2AuthenticationFailureHandler oAuth2AuthenticationFailureHandler()
@Bean @ConditionalOnMissingBean(value=org.springframework.security.web.authentication.AuthenticationFailureHandler.class) public org.springframework.security.web.authentication.AuthenticationFailureHandler authenticationFailureHandler()
@Bean @ConditionalOnMissingBean(value=org.springframework.security.access.PermissionEvaluator.class) public org.springframework.security.access.PermissionEvaluator permissionEvaluator()
@Bean @ConditionalOnMissingBean(value=org.springframework.security.core.userdetails.UserDetailsService.class) public <U extends AbstractUser<U,ID>,ID extends java.io.Serializable> org.springframework.security.core.userdetails.UserDetailsService userDetailService(AbstractUserRepository<U,ID> userRepository)
@Bean @ConditionalOnProperty(name="lemon.cors.allowed-origins") @ConditionalOnMissingBean(value=LemonCorsConfig.class) public LemonCorsConfig lemonCorsConfig(LemonProperties properties)
@Bean @ConditionalOnMissingBean(value=LemonOidcUserService.class) public LemonOidcUserService lemonOidcUserService(LemonOAuth2UserService<?,?> lemonOAuth2UserService)
@Bean @ConditionalOnMissingBean(value=LemonOAuth2UserService.class) public <U extends AbstractUser<U,ID>,ID extends java.io.Serializable> LemonOAuth2UserService<U,ID> lemonOAuth2UserService(LemonUserDetailsService<U,?> userDetailsService, LemonService<U,?> lemonService, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
@Bean @ConditionalOnMissingBean(value=JwtAuthenticationProvider.class) public <U extends AbstractUser<U,ID>,ID extends java.io.Serializable> JwtAuthenticationProvider<U,ID> jwtAuthenticationProvider(JwtService jwtService, LemonUserDetailsService<U,ID> userDetailsService)
@Bean @ConditionalOnMissingBean(value=LemonSecurityConfig.class) public LemonSecurityConfig lemonSecurityConfig()
@Bean @ConditionalOnMissingBean(value=LemonTokenAuthenticationFilter.class) public LemonTokenAuthenticationFilter lemonTokenAuthenticationFilter(LemonSecurityConfig lemonSecurityConfig) throws java.lang.Exception
java.lang.Exception
@Bean public LemonUtils lemonUtil(org.springframework.context.ApplicationContext applicationContext, org.springframework.context.MessageSource messageSource, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
@Bean @ConditionalOnMissingBean(value=CaptchaValidator.class) public CaptchaValidator captchaValidator(LemonProperties properties, org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder)
@Bean @ConditionalOnMissingBean(value=RetypePasswordValidator.class) public RetypePasswordValidator retypePasswordValidator()
@Bean public UniqueEmailValidator uniqueEmailValidator(AbstractUserRepository<?,?> userRepository)