I am using Spring Boot 2.1.1.RELEASE (spring-security-oauth2-2.3.4.RELEASE).
I would like to create a filter with precedence after TokenEndpoint#postAccessToken call. Why ? 'cause in that filter I want to take the token from the tokenStore and add it as a cookie to the response.
I would expect that, this will give me what I want:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.(...)
.addFilterAfter(new MyFilter(), BasicAuthenticationFilter.class);
}
But it doesn't. I can see, that BasicAuthenticationFilter is called after successfull authentication on oauth/token but it doesn't enter my MyFilter.
What am I suppose to do to call MyFilter after oauth/token call ?
You want to set cookie from authorization server or from resource server? Is your auth server and resource server both are in same context? or different applications.?
I have two microservices. First one is authorization server, that provides jwt tokens (signed by its private key). Second microservice is a resource server, that validates tokens based on authorization server public key (exposed via REST endpoint by Auth server)
Do you want to set after receiving access_token from authorization server? What > do you want to do by setting cookie?
No. I would like the authorization server to set a cookie when oauth/token call is made by the frontend application. That way the browser is responsible for adding a token to each request rather than my frontend app. That protects me against XSS attack, as the cookie will be set as httpOnly and secure.
Is your plan is to read cookie for getting access_token?
Correct. But that supposed to be done by resource server (haven't done that, yet)
simple way is to create an API for the same functionality. Which takes access_token as request parameter and sets the cookie.
Are you suggesting something like a proxy microservice that stands between frontend application and auth/resource servers ? proxy microservice that is setting jwt token as cookie, and read token from cookie ?

