Disclaimer I have never used Keycloak, but the wiki index says it is OAuth2 compatible, so I will trust this information.
At the highest level of vision, you have two requirements:
- Authenticate actions initiated by the end user when using your system.
- Authenticate actions initiated by your system at an unknown time, and where there is no need for the end user to be online.
You already met the first one, relying on an authentication system on tokens, and I would have done the same for the second point, the only difference would be that the tokens would be issued to your system using the OAuth2 client credentials instead of other grants intended for scenarios where there is an end user.
(source: Grant Client Credentials )
In your case, Keycloak will play the role of Auth0, and your client applications are microservices that can support client secrets used to authenticate with the authorization server and receive access tokens.
Keep in mind that if your system relies on the sub
application much more than on authentication and authorization, you may need to make some changes . For example, I saw systems running action A necessary to know that it was intended for users X and Y, but the payload for action only for user Y and intended user X was the current authenticated director. This works great when everything is synchronous, but just by switching the payload to indicate that both users mean that the action can be performed asynchronously using an authenticated system.
source share