use of org.springframework.security.web.server.SecurityWebFilterChain in project spring-security by spring-projects.
the class ServerHttpSecurityTests method addsX509FilterWhenX509AuthenticationIsConfigured.
@Test
@SuppressWarnings("unchecked")
public void addsX509FilterWhenX509AuthenticationIsConfigured() {
X509PrincipalExtractor mockExtractor = mock(X509PrincipalExtractor.class);
ReactiveAuthenticationManager mockAuthenticationManager = mock(ReactiveAuthenticationManager.class);
this.http.x509().principalExtractor(mockExtractor).authenticationManager(mockAuthenticationManager).and();
SecurityWebFilterChain securityWebFilterChain = this.http.build();
WebFilter x509WebFilter = securityWebFilterChain.getWebFilters().filter(this::isX509Filter).blockFirst();
assertThat(x509WebFilter).isNotNull();
}
use of org.springframework.security.web.server.SecurityWebFilterChain 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.SecurityWebFilterChain 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.SecurityWebFilterChain in project spring-security by spring-projects.
the class FormLoginTests method defaultLoginPage.
@Test
public void defaultLoginPage() {
// @formatter:off
SecurityWebFilterChain securityWebFilter = this.http.authorizeExchange().anyExchange().authenticated().and().formLogin().and().build();
WebTestClient webTestClient = WebTestClientBuilder.bindToWebFilters(securityWebFilter).build();
WebDriver driver = WebTestClientHtmlUnitDriverBuilder.webTestClientSetup(webTestClient).build();
// @formatter:on
DefaultLoginPage loginPage = HomePage.to(driver, DefaultLoginPage.class).assertAt();
// @formatter:off
loginPage = loginPage.loginForm().username("user").password("invalid").submit(DefaultLoginPage.class).assertError();
HomePage homePage = loginPage.loginForm().username("user").password("password").submit(HomePage.class);
// @formatter:on
homePage.assertAt();
loginPage = DefaultLogoutPage.to(driver).assertAt().logout();
loginPage.assertAt().assertLogout();
}
use of org.springframework.security.web.server.SecurityWebFilterChain 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