I try to implement a simple OAuth2 "Client Authentication with Signed JWT" Demo App using Spring Boot and Keycloak as AuthService.
The idea is:
- one secured REST service "The Producer"
- offering an endpoint GET /person for all users/principals with the role "read_person"
- offering an endpoint POST /person for all users/principals with the role "write_person"
- another (unsecured) REST service "The Consumer"
- offering an enpoint /api open for everybody
- calling internal the "producer" via
Feign
client using an RequestInterceptor to pass the AccessToken (signed JWT / JWS)
I read about the docs:
http://www.keycloak.org/docs/latest/securing_apps/topics/oidc/java/client-authentication.html
saying:
Once the client application is started, it allows to download its public >key in JWKS format using a URL such as http://myhost.com/myapp/k_jwks, >assuming that http://myhost.com/myapp is the base URL of your client >application. This URL can be used by Keycloak (see below).
During authentication, the client generates a JWT token and signs it with >its private key and sends it to Keycloak in the particular backchannel >request (for example, code-to-token request) in the client_assertion >parameter.
I googled a lot to find tutorials/demos or docs about this topic but failed so far. So here my questions:
How do I implement this "k_jwk" endpoint? Do I simple build a
@RestController
by myself in "the Producer"? How do I configure Keycloak to get aware of this URL?How do I implement my "Consumer" to get fresh signed JWT from Keycloak?
Update Removed irritating PS statement.