私はカスタム認証を実装しようとしていましたが、認証は正常に動作しますが、認証に問題があります。私はJWTトークンを使用しています。私はそれにアクセスしようとすると、403禁止されたエラーが表示されます。何が間違っているのか分かりません。私はgithubで完全なソースコードを持っています。 https://github.com/vivdso/SpringAuthentication、これでは春の起動マジックが動作しません。どんなポインタも適用されます。 MongoDbをリポジトリとして使用して、ユーザーアカウントとロールを格納します。以下は、
インメモリ認証が正常に動作しているが、カスタム認証は常に403をreturs私の私はWebSecurityConfigurerAdapterカスタム認証 - スプリングブート403禁止されたエラー
@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();
}
私は、認可のための任意のカスタム実装を持っていません。