I’m building a Spring Boot 3 web service with Spring Authorization Server and JDK 21, handling a multi-tenant system with custom authentication. The flow involves:
A third-party client (e.g., Team Tailor) initiates the OAuth2 Authorization Code flow to my auth2 service.
auth2 identifies the tenant based on the client ID, retrieves the tenant’s login URL, and redirects the user to the tenant for authentication (SSO or username/password).
After successful authentication, the tenant app returns a JWT to auth2.
auth2 reads claims (like username, user profile ID) from the tenant’s JWT and needs to pass this information to Spring Authorization Server to complete the flow and issue a new JWT for the third-party client.
Problem: How can I intercept the OAuth2 Authorization Code request, extract the client ID to find the tenant’s login URL, and avoid an infinite loop when the tenant redirects back with the JWT? I don’t want to manually generate a JWT; I just want to pass the tenant’s JWT claims into Spring Authorization Server and let it handle the final token issuance.
What is the best way to proceed with the flow after the tenant’s JWT is received, ensuring Spring Authorization Server handles the token generation?
The current flow which I think will work for me
In short what I want from Authroization Sever