-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Open
Labels
in: coreAn issue in spring-security-coreAn issue in spring-security-corestatus: blockedAn issue that's blocked on an external project changeAn issue that's blocked on an external project changetype: enhancementA general enhancementA general enhancement
Description
Summary
ReactiveSecurityContextHolder
is broken when used with Futures. It does not always provide results and sometimes just fires the onComplete signal.
Actual Behavior
Executes onComplete()
Expected Behavior
Should execute onNext()
Version
5.0.7 Release
Sample
@Test
public void testWorkingContext() {
Authentication authentication = new PreAuthenticatedAuthenticationToken("TEST", "");
Mono<String> working = ReactiveSecurityContextHolder.getContext()
.map(securityContext -> (String)securityContext.getAuthentication().getPrincipal());
Mono<String> stringMono = working.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(authentication));
StepVerifier.create(stringMono).expectNext("TEST").verifyComplete();
}
@Test
public void testBrokenContext() {
Authentication authentication = new PreAuthenticatedAuthenticationToken("TEST", "");
Mono<String> working = ReactiveSecurityContextHolder.getContext()
.map(securityContext -> (String)securityContext.getAuthentication().getPrincipal());
Mono<String> broken = Mono.fromFuture(working.toFuture());
Mono<String> stringMono = broken.subscriberContext(ReactiveSecurityContextHolder.withAuthentication(authentication));
StepVerifier.create(stringMono).expectNext("TEST").verifyComplete();
}
ahamednijamudeensa, burliayeu and braunsonm
Metadata
Metadata
Assignees
Labels
in: coreAn issue in spring-security-coreAn issue in spring-security-corestatus: blockedAn issue that's blocked on an external project changeAn issue that's blocked on an external project changetype: enhancementA general enhancementA general enhancement