|
|
|
@ -26,6 +26,7 @@ import org.springframework.security.authentication.ReactiveAuthenticationManager |
|
|
|
import org.springframework.security.authentication.UserDetailsRepositoryAuthenticationManager; |
|
|
|
import org.springframework.security.authentication.UserDetailsRepositoryAuthenticationManager; |
|
|
|
import org.springframework.security.config.web.server.HttpSecurity; |
|
|
|
import org.springframework.security.config.web.server.HttpSecurity; |
|
|
|
import org.springframework.security.core.userdetails.UserDetailsRepository; |
|
|
|
import org.springframework.security.core.userdetails.UserDetailsRepository; |
|
|
|
|
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder; |
|
|
|
import org.springframework.security.web.reactive.result.method.annotation.AuthenticationPrincipalArgumentResolver; |
|
|
|
import org.springframework.security.web.reactive.result.method.annotation.AuthenticationPrincipalArgumentResolver; |
|
|
|
import org.springframework.security.web.server.context.WebSessionSecurityContextRepository; |
|
|
|
import org.springframework.security.web.server.context.WebSessionSecurityContextRepository; |
|
|
|
import org.springframework.web.reactive.config.WebFluxConfigurer; |
|
|
|
import org.springframework.web.reactive.config.WebFluxConfigurer; |
|
|
|
@ -50,6 +51,9 @@ public class HttpSecurityConfiguration implements WebFluxConfigurer { |
|
|
|
@Autowired(required = false) |
|
|
|
@Autowired(required = false) |
|
|
|
private UserDetailsRepository userDetailsRepository; |
|
|
|
private UserDetailsRepository userDetailsRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired(required = false) |
|
|
|
|
|
|
|
private PasswordEncoder passwordEncoder; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) { |
|
|
|
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) { |
|
|
|
configurer.addCustomResolver(authenticationPrincipalArgumentResolver()); |
|
|
|
configurer.addCustomResolver(authenticationPrincipalArgumentResolver()); |
|
|
|
@ -57,7 +61,7 @@ public class HttpSecurityConfiguration implements WebFluxConfigurer { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public AuthenticationPrincipalArgumentResolver authenticationPrincipalArgumentResolver() { |
|
|
|
public AuthenticationPrincipalArgumentResolver authenticationPrincipalArgumentResolver() { |
|
|
|
return new AuthenticationPrincipalArgumentResolver(adapterRegistry); |
|
|
|
return new AuthenticationPrincipalArgumentResolver(this.adapterRegistry); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Bean(HTTPSECURITY_BEAN_NAME) |
|
|
|
@Bean(HTTPSECURITY_BEAN_NAME) |
|
|
|
@ -71,11 +75,16 @@ public class HttpSecurityConfiguration implements WebFluxConfigurer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ReactiveAuthenticationManager authenticationManager() { |
|
|
|
private ReactiveAuthenticationManager authenticationManager() { |
|
|
|
if(authenticationManager != null) { |
|
|
|
if(this.authenticationManager != null) { |
|
|
|
return authenticationManager; |
|
|
|
return this.authenticationManager; |
|
|
|
} |
|
|
|
} |
|
|
|
if(userDetailsRepository != null) { |
|
|
|
if(this.userDetailsRepository != null) { |
|
|
|
return new UserDetailsRepositoryAuthenticationManager(userDetailsRepository); |
|
|
|
UserDetailsRepositoryAuthenticationManager manager = |
|
|
|
|
|
|
|
new UserDetailsRepositoryAuthenticationManager(this.userDetailsRepository); |
|
|
|
|
|
|
|
if(this.passwordEncoder != null) { |
|
|
|
|
|
|
|
manager.setPasswordEncoder(this.passwordEncoder); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return manager; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|