Browse Source

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
pull/9160/head
Tomoki Tsubaki 5 years ago committed by Josh Cummings
parent
commit
e44471331b
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443
  1. 3
      web/src/main/java/org/springframework/security/web/server/csrf/CookieServerCsrfTokenRepository.java

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

@ -26,6 +26,7 @@ import org.springframework.util.StringUtils; @@ -26,6 +26,7 @@ import org.springframework.util.StringUtils;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
/**
* A {@link ServerCsrfTokenRepository} that persists the CSRF token in a cookie named "XSRF-TOKEN" and
@ -62,7 +63,7 @@ public final class CookieServerCsrfTokenRepository implements ServerCsrfTokenRep @@ -62,7 +63,7 @@ public final class CookieServerCsrfTokenRepository implements ServerCsrfTokenRep
@Override
public Mono<CsrfToken> generateToken(ServerWebExchange exchange) {
return Mono.fromCallable(this::createCsrfToken);
return Mono.fromCallable(this::createCsrfToken).subscribeOn(Schedulers.boundedElastic());
}
@Override

Loading…
Cancel
Save