springboot中使用Bcrypt加密类但不想对任何页面使用权限控制

1.使用Bcrypt加密类需要导入包

<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-security</artifactId>
</dependency>

注:springboot在导入该包后会自动对所有页面进行权限控制,开启spring-security权限控制。

2.放行所有页面
添加配置类即可:

@Configuration   //告诉项目这是个配置文件早点加载
@EnableWebSecurity //以实现Web安全性
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{//基类是个牛逼的类包含了很多涉及安全要使用的方法比如下面个重写的方法!

//下面这个方法简单的可以理解放开所有拦截!详细自己查!
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/**").permitAll()
.anyRequest().authenticated()
.and().csrf().disable();
}
}

3.Application启动类中添加一个加密工具类BcryptPasswordEncoder使用加密功能。

@Bean
prublic BcryptPasswordEncoder encoder(){
	return new BcryptPasswordEncoder();
}
@Autowired
private BcryptPasswordEncode encoder;

String newpassword = encoder.encoder(password);
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值