配置Spring Boot Security在Grails 3.0中使用BCrypt密码编码

配置Spring Boot Security在Grails 3.0中使用BCrypt密码编码,第1张

配置Spring Boot Security在Grails 3.0中使用BCrypt密码编码

我在下面的代码

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);    }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5621753.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存