Merge branch '6.2.x'
This commit is contained in:
@@ -83,7 +83,7 @@ public class WebfluxX509ApplicationITest {
|
||||
// @formatter:on
|
||||
|
||||
HttpClient httpClient = HttpClient.create()
|
||||
.secure((sslContextSpec) -> sslContextSpec.sslContext(sslContextBuilder));
|
||||
.secure((sslContextSpec) -> sslContextSpec.sslContext(sslContextBuilder));
|
||||
ClientHttpConnector httpConnector = new ReactorClientHttpConnector(httpClient);
|
||||
|
||||
// @formatter:off
|
||||
|
||||
@@ -34,8 +34,9 @@ public class MeController {
|
||||
|
||||
@GetMapping("/me")
|
||||
public Mono<String> me() {
|
||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication)
|
||||
.map((authentication) -> "Hello, " + authentication.getName());
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.map(SecurityContext::getAuthentication)
|
||||
.map((authentication) -> "Hello, " + authentication.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,12 +63,21 @@ public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
ReactiveUserDetailsService userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER")
|
||||
.build();
|
||||
UserDetails admin = User.withDefaultPasswordEncoder().username("admin").password("password").roles("ADMIN")
|
||||
.build();
|
||||
UserDetails unlimitedSessions = User.withDefaultPasswordEncoder().username("unlimited").password("password")
|
||||
.roles("UNLIMITED_SESSIONS").build();
|
||||
UserDetails user = User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build();
|
||||
UserDetails admin = User.withDefaultPasswordEncoder()
|
||||
.username("admin")
|
||||
.password("password")
|
||||
.roles("ADMIN")
|
||||
.build();
|
||||
UserDetails unlimitedSessions = User.withDefaultPasswordEncoder()
|
||||
.username("unlimited")
|
||||
.password("password")
|
||||
.roles("UNLIMITED_SESSIONS")
|
||||
.build();
|
||||
return new MapReactiveUserDetailsService(user, admin, unlimitedSessions);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,13 +93,20 @@ class MaximumSessionsApplicationPreventLoginTests {
|
||||
}
|
||||
|
||||
private ResponseCookie loginReturningCookie(MultiValueMap<String, String> data) {
|
||||
return login(data).expectCookie().exists("SESSION").returnResult(Void.class).getResponseCookies()
|
||||
.getFirst("SESSION");
|
||||
return login(data).expectCookie()
|
||||
.exists("SESSION")
|
||||
.returnResult(Void.class)
|
||||
.getResponseCookies()
|
||||
.getFirst("SESSION");
|
||||
}
|
||||
|
||||
private WebTestClient.ResponseSpec login(MultiValueMap<String, String> data) {
|
||||
return this.client.mutateWith(csrf()).post().uri("/login").contentType(MediaType.MULTIPART_FORM_DATA)
|
||||
.body(BodyInserters.fromFormData(data)).exchange();
|
||||
return this.client.mutateWith(csrf())
|
||||
.post()
|
||||
.uri("/login")
|
||||
.contentType(MediaType.MULTIPART_FORM_DATA)
|
||||
.body(BodyInserters.fromFormData(data))
|
||||
.exchange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,13 +94,20 @@ class MaximumSessionsApplicationTests {
|
||||
}
|
||||
|
||||
private ResponseCookie loginReturningCookie(MultiValueMap<String, String> data) {
|
||||
return login(data).expectCookie().exists("SESSION").returnResult(Void.class).getResponseCookies()
|
||||
.getFirst("SESSION");
|
||||
return login(data).expectCookie()
|
||||
.exists("SESSION")
|
||||
.returnResult(Void.class)
|
||||
.getResponseCookies()
|
||||
.getFirst("SESSION");
|
||||
}
|
||||
|
||||
private WebTestClient.ResponseSpec login(MultiValueMap<String, String> data) {
|
||||
return this.client.mutateWith(csrf()).post().uri("/login").contentType(MediaType.MULTIPART_FORM_DATA)
|
||||
.body(BodyInserters.fromFormData(data)).exchange();
|
||||
return this.client.mutateWith(csrf())
|
||||
.post()
|
||||
.uri("/login")
|
||||
.contentType(MediaType.MULTIPART_FORM_DATA)
|
||||
.body(BodyInserters.fromFormData(data))
|
||||
.exchange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user