Skip to content

Commit c7c20f0

Browse files
committed
chore: polishing PR
1 parent d8913e8 commit c7c20f0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

spring-boot-admin-samples/spring-boot-admin-sample-reactive/src/main/java/de/codecentric/boot/admin/SpringBootAdminReactiveApplication.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.springframework.security.config.Customizer;
2727
import org.springframework.security.config.web.server.ServerHttpSecurity;
2828
import org.springframework.security.web.server.SecurityWebFilterChain;
29+
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
30+
import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler;
2931
import org.springframework.security.web.server.authentication.logout.RedirectServerLogoutSuccessHandler;
3032
import org.springframework.security.web.server.authentication.logout.ServerLogoutSuccessHandler;
3133

@@ -64,19 +66,27 @@ public SecurityWebFilterChain securityWebFilterChainSecure(ServerHttpSecurity ht
6466
.pathMatchers(this.adminServer.path("/assets/**")).permitAll()
6567
.pathMatchers("/actuator/health/**").permitAll().pathMatchers(this.adminServer.path("/login"))
6668
.permitAll().anyExchange().authenticated())
67-
.formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login")))
68-
.logout((logout) -> logout
69-
.logoutUrl(this.adminServer.path("/logout"))
69+
.formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login"))
70+
.authenticationSuccessHandler(loginSuccessHandler(this.adminServer.path("/"))))
71+
.logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout"))
7072
.logoutSuccessHandler(logoutSuccessHandler(this.adminServer.path("/login?logout"))))
7173
.httpBasic(Customizer.withDefaults()).csrf(ServerHttpSecurity.CsrfSpec::disable).build();
7274
}
7375

74-
public ServerLogoutSuccessHandler logoutSuccessHandler(String uri) {
76+
// The following two methods are only required when setting a custom base-path (see
77+
// 'basepath' profile in application.yml)
78+
private ServerLogoutSuccessHandler logoutSuccessHandler(String uri) {
7579
RedirectServerLogoutSuccessHandler successHandler = new RedirectServerLogoutSuccessHandler();
7680
successHandler.setLogoutSuccessUrl(URI.create(uri));
7781
return successHandler;
7882
}
7983

84+
private ServerAuthenticationSuccessHandler loginSuccessHandler(String uri) {
85+
RedirectServerAuthenticationSuccessHandler successHandler = new RedirectServerAuthenticationSuccessHandler();
86+
successHandler.setLocation(URI.create(uri));
87+
return successHandler;
88+
}
89+
8090
@Bean
8191
public LoggingNotifier loggerNotifier(InstanceRepository repository) {
8292
return new LoggingNotifier(repository);

spring-boot-admin-samples/spring-boot-admin-sample-reactive/src/main/resources/application.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,8 @@ spring:
6060
user.name: "user" #These two are needed so that the server
6161
user.password: "password" #can access the protected client endpoints
6262

63-
63+
---
64+
spring:
65+
profiles: basepath
66+
webflux:
67+
base-path: /sba

0 commit comments

Comments
 (0)