Hi, I would like to create a centralized auth service to handle authentication and authorization between my microservices. I have an AngularJS front-end hosted on a NodeJS server, and an api server hosted on Jetty (Dropwizard framework) as the backend. I would like to use Pac4J to secure the REST endpoints on my backend, and to handle multiple authentication mechanisms and identity providers (username + password, Facebook, Twitter and LinkedIn), with stateless claim-based authentication based on JWTs . Additionally, I want to store a user’s Facebook access token so I can get Facebook resources on their behalf at a later time. The centralized auth service would expose endpoints to login with different identity providers, to get an access token with which to request resources from a given identity provider, and to refresh a JWT.
From reading the Pac4J documentation, it looks like I would use the dropwizard-pac4j package, and secure all protected endpoints except for the login endpoints with a JWT authorizer. Then I would implement the relevant OAuth client for each of my identity providers at these login endpoints (FacebookClient for the api/authentication/facebook/login , etc). After successfully authenticating with the identity provider and receiving a pac4j profile (like FacebookProfile for example), I could use the JWTGenerator to create a JWT. I would pass this JWT back to the client who would then store it and pass it in the Authorization header on successive calls to protected resources where it would be validated by a JWTAuthenticator.
When the JWT expires, the client could exchange it at my auth service for a new JWT, and if the client needs to access a Facebook resource for example they can likewise use their JWT to authorize a call to the auth service where it will return their long-lived Facebook access token from the database to be used for the client’s request to Facebook. I have crafted a sequence diagram to demonstrate my current understanding of the correct procedure, and would greatly appreciate feedback of whether I am on the right track. Thanks!