Mongodb 自定义身份验证-Spring启动403禁止错误

Mongodb 自定义身份验证-Spring启动403禁止错误,mongodb,authentication,spring-boot,jwt,http-status-code-403,Mongodb,Authentication,Spring Boot,Jwt,Http Status Code 403,我正在尝试实现自定义身份验证,身份验证工作正常,但在授权方面存在问题。我使用的是JWT令牌,任何我试图访问它的API都会抛出403禁止的错误。我不确定出了什么问题。我在github中有完整的源代码,Spring boot magic对此不起作用。任何指针都会被触动。 使用MongoDb作为我的存储库来存储用户帐户和角色。 InMemory身份验证工作正常,但自定义身份验证始终返回403,下面是我的I扩展WebSecurity配置适配器 @Autowired public void con

我正在尝试实现自定义身份验证,身份验证工作正常,但在授权方面存在问题。我使用的是JWT令牌,任何我试图访问它的API都会抛出403禁止的错误。我不确定出了什么问题。我在github中有完整的源代码,Spring boot magic对此不起作用。任何指针都会被触动。 使用MongoDb作为我的存储库来存储用户帐户和角色。
InMemory身份验证工作正常,但自定义身份验证始终返回403,下面是我的I扩展WebSecurity配置适配器

@Autowired
    public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
//        authenticationManagerBuilder.inMemoryAuthentication().withUser("admin").password("admin").roles("ADMIN");
//        authenticationManagerBuilder.inMemoryAuthentication().withUser("user").password("user").roles("USER");
authenticationManagerBuilder.authenticationProvider(getCustomAuthenticationProvider()); }

@Override
protected void configure(HttpSecurity http) throws Exception {
 http
                .authorizeRequests()
                .antMatchers(HttpMethod.GET, "/customer").hasAuthority("ADMIN")
                .antMatchers(HttpMethod.GET, "/order").hasAuthority("USER").and()
                .csrf().disable();
    }

@Bean
    protected CustomAuthenticationProvider getCustomAuthenticationProvider(){
        return new CustomAuthenticationProvider();
    }

我没有任何用于授权的自定义实现。

问题已经解决,我已经更新了Github存储库。spring引导安全性工作正常,问题是分配给用户集合的角色是Json字符串对象(例如{“role”:“role_ADMIN”}),而不是sting对象“role_ADMIN”


谢谢

问题已经解决,我已经更新了Github存储库。spring引导安全性工作正常,问题是分配给用户集合的角色是Json字符串对象(例如{“role”:“role_ADMIN”}),而不是sting对象“role_ADMIN”

谢谢