标签:取出 ble 技术 注解 word mem orm log 添加
.新建配置类SecurityConfig
//AOP实现,不更改其他代码,安全框架代替拦截器
//Enable注解表示开启功能
@EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter{ //授权 @Override protected void configure(HttpSecurity http) throws Exception { //首页所有人可以访问,功能页指定权限访问 //请求授权规则 http.authorizeRequests() .antMatchers("/").permitAll() .antMatchers("/level1/**").hasRole("vip1") .antMatchers("/level2/**").hasRole("vip2") .antMatchers("/level3/**").hasRole("vip3"); //没有权限默认跳转至登录页 http.formLogin(); } //认证 @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { //此处手动添加用户名密码,一般从DB中取出 //密码编码:passwordEncoder //springsecurity中新增很多加密方法 auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()) .withUser("alan").password(new BCryptPasswordEncoder().encode("123")).roles("vip1") .and() .withUser("root").password(new BCryptPasswordEncoder().encode("123")).roles("vip1","vip2","vip3"); } }
标签:取出 ble 技术 注解 word mem orm log 添加
原文地址:https://www.cnblogs.com/alanchenjh/p/12341131.html