I am building a OAuth2 Spring App which uses a client configured using Spring Authorization Server.
I have configured 2 custom endpoints for authorize
and token
endpoint like this in my application.yaml:
spring:
security:
oauth2:
client:
provider:
f7b6c040-b8fb-455c-8daa-9734d56d4eb0-test:
authorization-uri: http://api-gateway:5000/oauth2-token-mediator/pkce-authorize
token-uri: http://api-gateway:5000/oauth2-token-mediator/pkce-token
The authorize endpoint will do a redirect with the url and query params. It also sets a cookie on the path /issuer
. When the OAuth server calls my token
endpoint I am able to get all the query params but I don’t see the http cookie in my RestController.
I see the following in my app logs after redirecting from authorize
endpoint:
MyPkceController :set redirect url: http://api-gateway:9001/issuer/oauth2/authorize?response_ty [... redacted]
HttpEntityMethodProcessor : Nothing to write: null body
DispatcherServlet : Completed 307 TEMPORARY_REDIRECT
RestTemplate : HTTP POST http://api-gateway:5000/oauth2-token-mediator/pkce-token
I am not sure how to get my cookie in token
endpoint. I tried putting the cookie in various paths and I have not been successful.
I also put the following config in my Spring Authorization Server:
spring:
authorization-server:
forward-cookies: true
I can see the cookie in the Chrome browser in the Developers tool.