我在下面的代码
grails-app/conf/spring/resources.groovy
import org.springframework.security.crypto.bcrypt.BCryptPasswordEnprerbeans = { bcryptEnprer(BCryptPasswordEnprer)}
并且我有一个Java文件,该文件按照所述进行配置
spring-security。也可以在groovy中做到这一点,但是我在java中做到了。
import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;import org.springframework.security.core.userdetails.UserDetailsService;import org.springframework.security.crypto.bcrypt.BCryptPasswordEnprer;@Configuration@EnableWebMvcSecuritypublic class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired BCryptPasswordEnprer bcryptEnprer; @Autowired UserDetailsService myDetailsService @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { // userDetailsService should be changed to your user details service // password enprer being the bean defined in grails-app/conf/spring/resources.groovy auth.userDetailsService(myDetailsService) .passwordEnprer(bcryptEnprer); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)