use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class WebFluxSecurityConfigurationTests method loadConfigWhenBeanProxyingEnabledAndSubclassThenWebFilterChainProxyExists.
@Test
public void loadConfigWhenBeanProxyingEnabledAndSubclassThenWebFilterChainProxyExists() {
this.spring.register(ServerHttpSecurityConfiguration.class, ReactiveAuthenticationTestConfiguration.class, WebFluxSecurityConfigurationTests.SubclassConfig.class).autowire();
WebFilterChainProxy webFilterChainProxy = this.spring.getContext().getBean(WebFilterChainProxy.class);
assertThat(webFilterChainProxy).isNotNull();
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class ServerHttpSecurityTests method basicWithCustomAuthenticationManager.
@Test
public void basicWithCustomAuthenticationManager() {
ReactiveAuthenticationManager customAuthenticationManager = mock(ReactiveAuthenticationManager.class);
given(customAuthenticationManager.authenticate(any())).willReturn(Mono.just(new TestingAuthenticationToken("rob", "rob", "ROLE_USER", "ROLE_ADMIN")));
// @formatter:off
SecurityWebFilterChain securityFilterChain = this.http.httpBasic().authenticationManager(customAuthenticationManager).and().build();
// @formatter:on
WebFilterChainProxy springSecurityFilterChain = new WebFilterChainProxy(securityFilterChain);
// @formatter:off
WebTestClient client = WebTestClientBuilder.bindToWebFilters(springSecurityFilterChain).build();
client.get().uri("/").headers((headers) -> headers.setBasicAuth("rob", "rob")).exchange().expectStatus().isOk().expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok"));
// @formatter:on
verifyZeroInteractions(this.authenticationManager);
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class RequestCacheTests method requestCacheNoOp.
@Test
public void requestCacheNoOp() {
// @formatter:off
SecurityWebFilterChain securityWebFilter = this.http.authorizeExchange().anyExchange().authenticated().and().formLogin().and().requestCache().requestCache(NoOpServerRequestCache.getInstance()).and().build();
WebTestClient webTestClient = WebTestClient.bindToController(new SecuredPageController(), new WebTestClientBuilder.Http200RestController()).webFilter(new WebFilterChainProxy(securityWebFilter)).build();
WebDriver driver = WebTestClientHtmlUnitDriverBuilder.webTestClientSetup(webTestClient).build();
// @formatter:on
DefaultLoginPage loginPage = SecuredPage.to(driver, DefaultLoginPage.class).assertAt();
// @formatter:off
HomePage securedPage = loginPage.loginForm().username("user").password("password").submit(HomePage.class);
// @formatter:on
securedPage.assertAt();
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class RequestCacheTests method requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed.
@Test
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() {
// @formatter:off
SecurityWebFilterChain securityWebFilter = this.http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated()).formLogin(withDefaults()).requestCache((requestCache) -> requestCache.requestCache(NoOpServerRequestCache.getInstance())).build();
WebTestClient webTestClient = WebTestClient.bindToController(new SecuredPageController(), new WebTestClientBuilder.Http200RestController()).webFilter(new WebFilterChainProxy(securityWebFilter)).build();
WebDriver driver = WebTestClientHtmlUnitDriverBuilder.webTestClientSetup(webTestClient).build();
// @formatter:on
DefaultLoginPage loginPage = SecuredPage.to(driver, DefaultLoginPage.class).assertAt();
// @formatter:off
HomePage securedPage = loginPage.loginForm().username("user").password("password").submit(HomePage.class);
// @formatter:on
securedPage.assertAt();
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class FormLoginTests method formLoginWhenCustomLoginPageInLambdaThenUsed.
@Test
public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
// @formatter:off
SecurityWebFilterChain securityWebFilter = this.http.authorizeExchange((exchanges) -> exchanges.pathMatchers("/login").permitAll().anyExchange().authenticated()).formLogin((formLogin) -> formLogin.loginPage("/login")).build();
WebTestClient webTestClient = WebTestClient.bindToController(new CustomLoginPageController(), new WebTestClientBuilder.Http200RestController()).webFilter(new WebFilterChainProxy(securityWebFilter)).build();
WebDriver driver = WebTestClientHtmlUnitDriverBuilder.webTestClientSetup(webTestClient).build();
// @formatter:on
CustomLoginPage loginPage = HomePage.to(driver, CustomLoginPage.class).assertAt();
// @formatter:off
HomePage homePage = loginPage.loginForm().username("user").password("password").submit(HomePage.class);
// @formatter:on
homePage.assertAt();
}
Aggregations