Javadoc @EnableWebFluxSecurity
This commit is contained in:
parent
b394ae5d5e
commit
f040bd054d
|
@ -18,10 +18,64 @@ package org.springframework.security.config.annotation.web.reactive;
|
|||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Add this annotation to a {@code Configuration} class to have Spring Security WebFlux
|
||||
* support added. User's can then create one or more {@link ServerHttpSecurity}
|
||||
* {@code Bean} instances.
|
||||
*
|
||||
* A minimal configuration can be found below:
|
||||
*
|
||||
* <pre class="code">
|
||||
* @EnableWebFluxSecurity
|
||||
* public class MyMinimalSecurityConfiguration {
|
||||
*
|
||||
* @Bean
|
||||
* public MapReactiveUserDetailsService userDetailsRepository() {
|
||||
* UserDetails user = User.withDefaultPasswordEncoder()
|
||||
* .username("user")
|
||||
* .password("password")
|
||||
* .roles("USER")
|
||||
* .build();
|
||||
* return new MapReactiveUserDetailsService(user);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Below is the same as our minimal configuration, but explicitly declaring the
|
||||
* {@code ServerHttpSecurity}.
|
||||
*
|
||||
* <pre class="code">
|
||||
* @EnableWebFluxSecurity
|
||||
* public class MyExplicitSecurityConfiguration {
|
||||
* @Bean
|
||||
* SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
* http
|
||||
* .authorizeExchange()
|
||||
* .anyExchange().authenticated()
|
||||
* .and()
|
||||
* .httpBasic().and()
|
||||
* .formLogin();
|
||||
* return http.build();
|
||||
* }
|
||||
*
|
||||
* @Bean
|
||||
* public MapReactiveUserDetailsService userDetailsRepository() {
|
||||
* UserDetails user = User.withDefaultPasswordEncoder()
|
||||
* .username("user")
|
||||
* .password("password")
|
||||
* .roles("USER")
|
||||
* .build();
|
||||
* return new MapReactiveUserDetailsService(user);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
|
|
|
@ -35,7 +35,7 @@ import static org.springframework.security.config.web.server.ServerHttpSecurity.
|
|||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ServerHttpSecurityConfiguration implements WebFluxConfigurer {
|
||||
class ServerHttpSecurityConfiguration implements WebFluxConfigurer {
|
||||
private static final String BEAN_NAME_PREFIX = "org.springframework.security.config.annotation.web.reactive.HttpSecurityConfiguration.";
|
||||
private static final String HTTPSECURITY_BEAN_NAME = BEAN_NAME_PREFIX + "httpSecurity";
|
||||
|
||||
|
|
Loading…
Reference in New Issue