【问题标题】:Oauth protected rest api is working without bearer tokenOauth 保护的 rest api 在没有承载令牌的情况下工作
【发布时间】:2020-07-14 06:05:01
【问题描述】:

Rest 端点受OAuth 保护,但出于某种原因,我可以在没有令牌的情况下点击/users/user。请让我知道缺少什么。

在我的资源类中,我提到了以下配置来保护端点。

@Override
    public void configure(HttpSecurity http) throws Exception {
        http.
                anonymous().disable()
                .authorizeRequests()
                .antMatchers("/users/**")
                .access("hasRole('ADMIN')")
                .and()
                .exceptionHandling()
                .accessDeniedHandler(new OAuth2AccessDeniedHandler());
    }

【问题讨论】:

    标签: java spring-boot rest oauth


    【解决方案1】:

    也许需要更多信息,但试试这个:

    @Override public void configure(HttpSecurity http) throws Exception { 
       http.authorizeRequests()
       .antMatchers("/users*//**").access("hasRole('ADMIN')")
       .and().exceptionHandling()
       .accessDeniedHandler(new OAuth2AccessDeniedHandler()); 
    }
    
    or original pattern "/users/**"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 2019-08-24
      • 2019-08-06
      • 2021-08-01
      • 2011-02-18
      • 2021-02-27
      相关资源
      最近更新 更多