use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class ServerHttpSecurityTests method buildWhenServerWebExchangeFromContextThenFound.
@Test
public void buildWhenServerWebExchangeFromContextThenFound() {
SecurityWebFilterChain filter = this.http.build();
// @formatter:off
WebTestClient client = WebTestClient.bindToController(new SubscriberContextController()).webFilter(new WebFilterChainProxy(filter)).build();
client.get().uri("/foo/bar").exchange().expectBody(String.class).isEqualTo("/foo/bar");
// @formatter:on
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class ServerHttpSecurityTests method requestWhenBasicWithAuthenticationManagerInLambdaThenAuthenticationManagerUsed.
@Test
public void requestWhenBasicWithAuthenticationManagerInLambdaThenAuthenticationManagerUsed() {
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((httpBasic) -> httpBasic.authenticationManager(customAuthenticationManager)).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);
verify(customAuthenticationManager).authenticate(any(Authentication.class));
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class FormLoginTests method customLoginPage.
@Test
public void customLoginPage() {
// @formatter:off
SecurityWebFilterChain securityWebFilter = this.http.authorizeExchange().pathMatchers("/login").permitAll().anyExchange().authenticated().and().formLogin().loginPage("/login").and().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();
}
use of org.springframework.security.web.server.WebFilterChainProxy in project spring-security by spring-projects.
the class WebFluxSecurityConfigurationTests method loadConfigWhenReactiveUserDetailsServiceConfiguredThenWebFilterChainProxyExists.
@Test
public void loadConfigWhenReactiveUserDetailsServiceConfiguredThenWebFilterChainProxyExists() {
this.spring.register(ServerHttpSecurityConfiguration.class, ReactiveAuthenticationTestConfiguration.class, WebFluxSecurityConfiguration.class).autowire();
WebFilterChainProxy webFilterChainProxy = this.spring.getContext().getBean(WebFilterChainProxy.class);
assertThat(webFilterChainProxy).isNotNull();
}
Aggregations