com.healthy.common.security.authentication.AuthenticationBeanConfig Maven / Gradle / Ivy
package com.healthy.common.security.authentication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.social.security.SocialUserDetailsService;
/**
* Certification-related extension point configuration.
* You can override the default configuration by declaring beans of the same type or the same name.
*
* @author xiaomingzhang
*/
@Configuration
public class AuthenticationBeanConfig {
/**
* Default PasswordEncoder
*
* @return BCryptPasswordEncoder
*/
@Bean
@ConditionalOnMissingBean(PasswordEncoder.class)
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
/**
* Default UserDetailsService
*
* @return UserDetailsService
*/
@Bean
@ConditionalOnMissingBean(UserDetailsService.class)
public UserDetailsService userDetailsService() {
return new DefaultUserDetailsService();
}
/**
* Default SocialUserDetailsService
*
* @return SocialUserDetailsService
*/
@Bean
@ConditionalOnMissingBean(SocialUserDetailsService.class)
public SocialUserDetailsService socialUserDetailsService() {
return new DefaultSocialUserDetailsService();
}
}