spring security 5.x去除默认前缀

.antMatchers("/**/users/admin/**").access("hasAnyRole('ADMIN')")  .antMatchers("/**/users/test/**").access("hasAnyRole('USER')")
.antMatchers("/**/users/test/**").hasRole('USER')

 
@EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true)//启用方法级的权限认证@EnableWebSecuritypublic class SecurityConfiguration extends WebSecurityConfigurerAdapter {
 /**
     * 干掉默认的授权前缀
     * 工作方式.access("hasRole('USER')")而不是 hasRole('USER')
     */
    @Bean
    GrantedAuthorityDefaults grantedAuthorityDefaults() {
        return new GrantedAuthorityDefaults(""); // Remove the ROLE_ prefix
    }}


本文作者:admin

本文链接:https://www.javalc.com/post/27.html

版权声明:本篇文章于2020-10-19,由admin发表,转载请注明出处:分享你我。如有疑问,请联系我们

vue 使用render 动态创建element ui table 增强版

发表评论

取消
扫码支持