mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
Polish Automatically Add CsrfServerLogoutHandler
Issue: gh-5337
This commit is contained in:
parent
b060ec050a
commit
45a9c0fd54
@ -1608,7 +1608,7 @@ public class ServerHttpSecurity {
|
|||||||
protected void configure(ServerHttpSecurity http) {
|
protected void configure(ServerHttpSecurity http) {
|
||||||
Optional.ofNullable(this.csrfTokenRepository).ifPresent(serverCsrfTokenRepository -> {
|
Optional.ofNullable(this.csrfTokenRepository).ifPresent(serverCsrfTokenRepository -> {
|
||||||
this.filter.setCsrfTokenRepository(serverCsrfTokenRepository);
|
this.filter.setCsrfTokenRepository(serverCsrfTokenRepository);
|
||||||
http.logout().logoutHandler(new CsrfServerLogoutHandler(serverCsrfTokenRepository));
|
http.logout().addLogoutHandler(new CsrfServerLogoutHandler(serverCsrfTokenRepository));
|
||||||
});
|
});
|
||||||
http.addFilterAt(this.filter, SecurityWebFiltersOrder.CSRF);
|
http.addFilterAt(this.filter, SecurityWebFiltersOrder.CSRF);
|
||||||
}
|
}
|
||||||
@ -2350,10 +2350,14 @@ public class ServerHttpSecurity {
|
|||||||
* @return the {@link LogoutSpec} to configure
|
* @return the {@link LogoutSpec} to configure
|
||||||
*/
|
*/
|
||||||
public LogoutSpec logoutHandler(ServerLogoutHandler logoutHandler) {
|
public LogoutSpec logoutHandler(ServerLogoutHandler logoutHandler) {
|
||||||
if (logoutHandler != null) {
|
Assert.notNull(logoutHandler, "logoutHandler cannot be null");
|
||||||
this.logoutHandlers.add(logoutHandler);
|
this.logoutHandlers.clear();
|
||||||
|
return addLogoutHandler(logoutHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LogoutSpec addLogoutHandler(ServerLogoutHandler logoutHandler) {
|
||||||
|
Assert.notNull(logoutHandler, "logoutHandler cannot be null");
|
||||||
|
this.logoutHandlers.add(logoutHandler);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user