侧边栏壁纸
博主头像
分享你我博主等级

行动起来,活在当下

  • 累计撰写 106 篇文章
  • 累计创建 13 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

spring security 5.x去除默认前缀

管理员
2020-10-09 / 0 评论 / 0 点赞 / 2 阅读 / 924 字

.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

    }}


0

评论区