Issue with Public Key Retrieval in InfinispanPublicKeyStorageProvider
Hello everyone,
I am encountering an issue with the public key retrieval mechanism in the InfinispanPublicKeyStorageProvider class of Keycloak. Here is a brief overview of the problem:
Problem Description
In my setup, I am using Keycloak to manage authentication and authorization, and the public keys are stored and retrieved using Infinispan. Recently, I observed the following error in the logs:
.2024-07-25T12:42:11.231Z 2024-07-25 12:42:11,231 DEBUG [org.keycloak.keys.infinispan.InfinispanPublicKeyStorageProvider] (executor-thread-38) Public keys retrieved successfully for model <model-id>::idp::<idp-id>. New kids: [<key-id-1>, <key-id-2>, <key-id-3>, <key-id-4>, <key-id-5>, <key-id-6>, <key-id-7>, <key-id-8>, <key-id-9>, <key-id-10>, <key-id-11>, <key-id-12>, <key-id-13>, <key-id-14>, <key-id-15>]
2024-07-25 12:42:11,232 WARN [org.keycloak.keys.infinispan.InfinispanPublicKeyStorageProvider] (executor-thread-38) PublicKey wasn't found in the storage. Requested kid: 'symmetrickey'. Available kids: '[<key-id-1>, <key-id-2>, <key-id-3>, <key-id-4>, <key-id-5>, <key-id-6>, <key-id-7>, <key-id-8>, <key-id-9>, <key-id-10>, <key-id-11>, <key-id-12>, <key-id-13>, <key-id-14>, <key-id-15>]'
2024-07-25T12:42:11.232Z 2024-07-25 12:42:11,232 DEBUG [org.keycloak.broker.oidc.OIDCIdentityProvider] (executor-thread-38) Failed to verify token, key not found for algorithm HS256
2024-07-25 12:42:11,233 ERROR [org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider] (executor-thread-38) Failed to make identity provider oauth callback: org.keycloak.broker.provider.IdentityBrokerException: token signature validation failed
Issue
Despite the keys being retrieved successfully, the specific key with the identifier symmetrickey is not found, resulting in a failure to verify the token. The logs show that the available key identifiers do not include symmetrickey, and an error occurs due to the key for algorithm HS256 not being found.
Deployment Details
We have deployed Keycloak 24.0.3 on Google Kubernetes Engine (GKE) with Cloud Armor and Palo Alto in TCP mode. We use an existing OpenID Connect SSO
Request for Help
I am looking for advice on how to resolve this issue. Specifically, I need assistance with:
- Ensuring that the requested key identifier (
symmetrickey) is available in the cache or properly loaded if not present. - Debugging steps or additional logging that might help identify why the key is missing despite successful retrieval of other keys.
Any guidance or suggestions on how to address this problem would be greatly appreciated.
Thank you!