In this tutorial the author uses a global variable for the RestTemplate
in a @Controller
.
For an incoming request, he extracts the Bearer token out of the request and adds an interceptor that adds the token to the outgoing requests of the RestTemplate
.
I think, there might be a race condition. A request of a second user might get the interceptor from a first user and therefore authenticates as the first user.
According to Okta, they tested the code and did not experience any race condition. Is there some mechanism in Spring that ensures this?