0
点赞
收藏
分享

微信扫一扫

五分钟带你玩转oauth2(二十一)spring security+oauth2资源服务器开放swaager访问

徐一村 2022-03-11 阅读 66


资源服务器不像认证服务器可以直接配置 ,资源服务器只能配置每个接口权限

http.sessionManagement()
// SpringSecurity不会使用也不会创建HttpSession实例
.sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests()
// swagger请求
.antMatchers("/swagger-ui.html", "/webjars/**", "/swagger-resources/**","/v2/**").permitAll()
// 所有请求,都需要有all范围(scope)
.antMatchers("/**").access("#oauth2.hasScope('xxx')").anyRequest().authenticated().and().csrf()
.disable();



举报

相关推荐

0 条评论