I will use Google credentials to perform SSO and redirect to keycloak for authentication. I will use Keycloak auth token for authentication and authorization in my spring boot microservice.
Login with admin and create new realm.
- Provide client id, name etc.
- Set Client authentication on.
- Provide Valid redirect URI http://localhost:8081/login/oauth2/code/mono-client
- Copy client id and secret and update in application.properties.
- Go to the Realm Roles and crate a new role as admin.
- Set the identity provider as Google.
- Put the copied id and secret in previous step.
- Go to Mapper and create a new mapper.
- Select Mapper type as Hardcoded role.
- Map the role "admin".
Access http://localhost:8081/demo You will be redirected to Keycloak login page. Choose Google and login with your google account.
You will be redirected to your application and you can see keycloak token in cookie.