當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
SpringSecurity分布式整合之认证服务配置文件编写和测试
生活随笔
收集整理的這篇文章主要介紹了
SpringSecurity分布式整合之认证服务配置文件编写和测试
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
編寫SpringSecurity配置類
@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled=true) public class WebSecurityConfig extends WebSecurityConfigurerAdapter {@Autowiredprivate UserService userService;@Autowiredprivate RsaKeyProperties prop;@Beanpublic BCryptPasswordEncoder passwordEncoder(){return new BCryptPasswordEncoder();}//指定認(rèn)證對(duì)象的來源public void configure(AuthenticationManagerBuilder auth) throws Exception {auth.userDetailsService(userService).passwordEncoder(passwordEncoder());}//SpringSecurity配置信息public void configure(HttpSecurity http) throws Exception {http.csrf().disable().authorizeRequests().antMatchers("/product").hasAnyRole("USER").anyRequest().authenticated().and().addFilter(new JwtLoginFilter(super.authenticationManager(), prop)).addFilter(new JwtVerifyFilter(super.authenticationManager(), prop)).sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);} }總結(jié)
以上是生活随笔為你收集整理的SpringSecurity分布式整合之认证服务配置文件编写和测试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringSecurity分布式整合之
- 下一篇: SpringSecurity分布式整合之