There is an Endpoint to a backend server which gives a JSON response on pinging and is protected by an Apigee Edge Proxy. Currently, this endpoint has no security and we want to implement Bearer only token authentication for all the clients making the request. All the clients making the requests to API will send that JWT token in Authorization Bearer and Apigee Edge will be used to verify the JWT Token.
How do I use Keycloak to generate this JWT token?
Also, Apigee needs a public key of the origin of the JWT token (the server which signed the JWT token, in this case, I believe that is Keycloak). So my second doubt is, while I use Keycloak to generate the JWT token, how to get the public key using which the server will verify if the token is valid?
This got figured out with the help of this medium article. All the steps I have mentioned below have a detailed description in the article (Refer step 1 to 9 for token part, other steps are related to Spring Boot application) but I would like to give a overview of those in reference to my question.
Generating a JWT token using KeyCloak
openid-connect
as theClient Protocol
.localhost
, visiting the http://localhost:8080/auth/realms/dev/.well-known/openid-configuration gives details about all security endpointsGetting the public key of the KeyCloak server
Realm Settings
and click onPublic key
pops up with the Public key of the server for that Realm. Refer to this image for better understanding.-----BEGIN PUBLIC KEY-----
and append-----END PUBLIC KEY-----
to this copied public key to use it anywhere to verify the JWTtoken. You public key should finally look something like this:Validating the token on a third party platform