| | |
| | | */ |
| | | package com.vci.ubcs.admin.config; |
| | | |
| | | import com.vci.ubcs.admin.security.CustomAuthenticationManager; |
| | | import de.codecentric.boot.admin.server.config.AdminServerProperties; |
| | | import com.vci.ubcs.admin.security.InternalAuthorizationManager; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.ReactiveAuthenticationManager; |
| | | import org.springframework.security.authorization.ReactiveAuthorizationManager; |
| | | import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; |
| | | import org.springframework.security.config.web.server.ServerHttpSecurity; |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.web.server.SecurityWebFilterChain; |
| | | import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler; |
| | | import org.springframework.security.web.server.authorization.AuthorizationContext; |
| | | |
| | | import java.net.URI; |
| | | |
| | |
| | | } |
| | | |
| | | @Bean |
| | | public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { |
| | | public CustomAuthenticationManager customAuthenticationManager(UserDetailsService userDetailsService) { |
| | | return new CustomAuthenticationManager(userDetailsService); |
| | | } |
| | | |
| | | @Bean |
| | | public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http, CustomAuthenticationManager customAuthenticationManager) { |
| | | // @formatter:off |
| | | RedirectServerAuthenticationSuccessHandler successHandler = new RedirectServerAuthenticationSuccessHandler(); |
| | | successHandler.setLocation(URI.create(contextPath + "/")); |
| | |
| | | .pathMatchers( |
| | | contextPath + "/assets/**" |
| | | , contextPath + "/login" |
| | | , contextPath + "/applications" |
| | | , contextPath + "/v1/agent/**" |
| | | , contextPath + "/v1/catalog/**" |
| | | , contextPath + "/v1/health/**" |
| | |
| | | .pathMatchers(contextPath + "/actuator", contextPath + "/actuator/**").access(new InternalAuthorizationManager()) |
| | | .anyExchange().authenticated().and() |
| | | .formLogin().loginPage(contextPath + "/login") |
| | | .authenticationSuccessHandler(successHandler).and() |
| | | .authenticationSuccessHandler(successHandler) |
| | | .authenticationManager(customAuthenticationManager).and() |
| | | .logout().logoutUrl(contextPath + "/logout").and() |
| | | .httpBasic().disable() |
| | | .csrf().disable() |