REST Backbone with Keycloak Secure Key

I have two webapps. Each of them has an interface (AngularJS) and a backend (Java). Each interface has its own keycloak.json configuration file for open access. Each backend has its own keycloak.json file for access to the type of access. Each frontend application works great with its own backend. My task is to make a REST call to each other (backend for backend). How could I achieve this? Since on each backend, REST services are protected by checking the validity of the token.

+7
keycloak
source share
1 answer

If all of these backend services are protected by keycloak, see the KeycloakRestTemplate RestTemplate extension in the keyclayak Spring adapter. KeycloakRestTemplate is imported as part of the jar dependency on keycloak-spring-security-adapter.

Basically, it uses KeycloakClientRequestFactory and internally, adds an authorization header (for the current authenticated principal) to all service requests to service calls.

https://github.com/keycloak/keycloak/blob/master/adapters/oidc/spring-security/src/main/java/org/keycloak/adapters/springsecurity/client/KeycloakRestTemplate.java

0
source share

All Articles