Added csrf protection matcher to exclude bearer token calls from csfr
This commit is contained in:
parent
98e69164ed
commit
9bf148a09f
1 changed files with 10 additions and 1 deletions
|
|
@ -91,9 +91,18 @@ public class SecurityConfig {
|
|||
)
|
||||
.csrf(csrf -> csrf
|
||||
.ignoringRequestMatchers("/oauth2/token") // CSRF für OAuth deaktivieren
|
||||
.ignoringRequestMatchers("/login/oauth2/code/**")
|
||||
.requireCsrfProtectionMatcher(request -> {
|
||||
|
||||
String authHeader = request.getHeader("Authorization");
|
||||
if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
|
||||
.csrfTokenRequestHandler(new LccCsrfTokenRequestHandler())
|
||||
.ignoringRequestMatchers("/login/oauth2/code/**")
|
||||
)
|
||||
.addFilterAfter(new CsrfCookieFilter(), BasicAuthenticationFilter.class)
|
||||
.addFilterBefore(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue