I have 2 spring web apps that provide 2 separate set of services. Web App 1 has Spring Security implemented using a user-based authentication.
Now, Web App 2 needs
The currently authenticated user credentials should be available in Web App 1 on Authentication
object, which is accessible through SecurityContext
(for example, you can retrieve it by calling SecurityContextHolder.getContext().getAuthentication()
).
After you retrieve the credentials, you can use them to access Web App 2.
You can pass "Authentiation" header with RestTemplate by either extending it with a decorator (as described here) or using RestTemplate.exchange()
method, as described in this forum post.