に春のセキュリティ保護から1つのURIを除外するために失敗私は、次のようなHttpSecurity
がありますはPOSTリクエスト
http
.exceptionHandling().and()
.anonymous().and()
.servletApi().and()
.headers().cacheControl().and().and()
.authorizeRequests()
// Need authentication sur POST
.antMatchers(HttpMethod.POST).authenticated()
// Allow anonymous resource requests
.anyRequest().permitAll().and()
// Custom Token based authentication based on the header previously given to the client
.addFilterBefore(new StatelessAuthenticationFilter(tokenAuthenticationService),
UsernamePasswordAuthenticationFilter.class)
// Filtre pour gérer la clef d'api
.addFilterBefore(new ApiKeyFilter(), StatelessAuthenticationFilter.class)
// Filtre pour ajouter les headers nécessaires à la consommation par les différents clients
.addFilterBefore(new CorsFilter(), ApiKeyFilter.class);
問題は、私は403 Forbidden
応答を得ることなく/user
にPOST
にできるようにする必要があるということです。そこで、/user
に匿名リクエストを許可するルールを追加して、POST
としました。
.antMatchers(HttpMethod.POST, "/user").anonymous()
が、問題は、私はこれを追加する場所がわからないということです、私は.antMatchers(HttpMethod.POST, "/user").anonymous()
の前と後にしようとしたが、私はまだ403
を取得するので、それは無視されているように思える:
antMatcher
を使用しました。