Skip to content

Commit

Permalink
chore: polishing PR
Browse files Browse the repository at this point in the history
  • Loading branch information
SteKoe committed Jul 8, 2022
1 parent d8913e8 commit c7c20f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.springframework.security.config.Customizer;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler;
import org.springframework.security.web.server.authentication.logout.RedirectServerLogoutSuccessHandler;
import org.springframework.security.web.server.authentication.logout.ServerLogoutSuccessHandler;

Expand Down Expand Up @@ -64,19 +66,27 @@ public SecurityWebFilterChain securityWebFilterChainSecure(ServerHttpSecurity ht
.pathMatchers(this.adminServer.path("/assets/**")).permitAll()
.pathMatchers("/actuator/health/**").permitAll().pathMatchers(this.adminServer.path("/login"))
.permitAll().anyExchange().authenticated())
.formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login")))
.logout((logout) -> logout
.logoutUrl(this.adminServer.path("/logout"))
.formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login"))
.authenticationSuccessHandler(loginSuccessHandler(this.adminServer.path("/"))))
.logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout"))
.logoutSuccessHandler(logoutSuccessHandler(this.adminServer.path("/login?logout"))))
.httpBasic(Customizer.withDefaults()).csrf(ServerHttpSecurity.CsrfSpec::disable).build();
}

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

private ServerAuthenticationSuccessHandler loginSuccessHandler(String uri) {
RedirectServerAuthenticationSuccessHandler successHandler = new RedirectServerAuthenticationSuccessHandler();
successHandler.setLocation(URI.create(uri));
return successHandler;
}

@Bean
public LoggingNotifier loggerNotifier(InstanceRepository repository) {
return new LoggingNotifier(repository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ spring:
user.name: "user" #These two are needed so that the server
user.password: "password" #can access the protected client endpoints


---
spring:
profiles: basepath
webflux:
base-path: /sba

0 comments on commit c7c20f0

Please sign in to comment.