BearerTokenServerAuthenticationEntryPoint waits for subscriber
Fixes: gh-5742
This commit is contained in:
parent
362c2ef1f2
commit
713e1e3356
|
@ -58,6 +58,7 @@ public final class BearerTokenServerAuthenticationEntryPoint implements
|
|||
|
||||
@Override
|
||||
public Mono<Void> commence(ServerWebExchange exchange, AuthenticationException authException) {
|
||||
return Mono.defer(() -> {
|
||||
HttpStatus status = getStatus(authException);
|
||||
|
||||
Map<String, String> parameters = createParameters(authException);
|
||||
|
@ -66,6 +67,7 @@ public final class BearerTokenServerAuthenticationEntryPoint implements
|
|||
response.getHeaders().set(HttpHeaders.WWW_AUTHENTICATE, wwwAuthenticate);
|
||||
response.setStatusCode(status);
|
||||
return response.setComplete();
|
||||
});
|
||||
}
|
||||
|
||||
private Map<String, String> createParameters(AuthenticationException authException) {
|
||||
|
|
|
@ -91,6 +91,14 @@ public class BearerTokenServerAuthenticationEntryPointTests {
|
|||
assertThat(getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commenceWhenNoSubscriberThenNothingHappens() {
|
||||
this.entryPoint.commence(this.exchange, new BadCredentialsException(""));
|
||||
|
||||
assertThat(getResponse().getHeaders()).isEmpty();
|
||||
assertThat(getResponse().getStatusCode()).isNull();
|
||||
}
|
||||
|
||||
private MockServerHttpResponse getResponse() {
|
||||
return this.exchange.getResponse();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue