Skip to content

Commit 5bce912

Browse files
tt4gjzheaux
authored andcommitted
Create the CSRF token on the bounded elactic scheduler
The CSRF token is generated by UUID.randomUUID() which is I/O blocking operation. This commit changes the subscriber thread to the bounded elactic scheduler. Closes gh-9018
1 parent dfa741f commit 5bce912

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web/src/main/java/org/springframework/security/web/server/csrf/CookieServerCsrfTokenRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.web.server.ServerWebExchange;
2828

2929
import reactor.core.publisher.Mono;
30+
import reactor.core.scheduler.Schedulers;
3031

3132
/**
3233
* A {@link ServerCsrfTokenRepository} that persists the CSRF token in a cookie named "XSRF-TOKEN" and
@@ -63,7 +64,7 @@ public static CookieServerCsrfTokenRepository withHttpOnlyFalse() {
6364

6465
@Override
6566
public Mono<CsrfToken> generateToken(ServerWebExchange exchange) {
66-
return Mono.fromCallable(this::createCsrfToken);
67+
return Mono.fromCallable(this::createCsrfToken).subscribeOn(Schedulers.boundedElastic());
6768
}
6869

6970
@Override

0 commit comments

Comments
 (0)