8000 Surface Kubernetes IdP key-loading failures and fix a resulting NPE by onematchfox · Pull Request #51686 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ private boolean verifySignature(AbstractJWTClientValidator validator) {

String modelKey = PublicKeyStorageUtils.getIdpModelCacheKey(validator.getContext().getRealm().getId(), config.getInternalId());
PublicKeyStorageProvider keyStorage = session.getProvider(PublicKeyStorageProvider.class);
KeyWrapper publicKey = keyStorage.getPublicKey(modelKey, kid, alg, new KubernetesJwksEndpointLoader(session, config.getIssuer()));

KeyWrapper publicKey;
try {
publicKey = keyStorage.getPublicKey(modelKey, kid, alg, new KubernetesJwksEndpointLoader(session, config.getIssuer()));
} catch (Exception e) {
// Indicative of an infrastructure/configuration and can't be
// triggered by a client - worth WARN visibility.
LOGGER.warnf(e, "Failed to load public keys for Kubernetes IdP '%s' with issuer '%s'", config.getAlias(), config.getIssuer());
Comment thread
onematchfox marked this conversation as resolved.
Resolved
return false;
}

SignatureProvider signatureProvider = session.getProvider(SignatureProvider.class, alg);
if (signatureProvider == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.keycloak.broker.kubernetes;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.keycloak.crypto.PublicKeysWrapper;
Expand Down Expand Up @@ -46,6 +47,9 @@ public PublicKeysWrapper loadKeys() throws Exception {
wellKnownReqest.auth(token);
}
String jwksUri = wellKnownReqest.asJson(OIDCConfigurationRepresentation.class).getJwksUri();
if (jwksUri == null) {
throw new IOException("OIDC discovery document from " + wellKnownEndpoint + " did not include a jwks_uri");
Comment thread
pedroigor marked this conversation as resolved.
Resolved
}

SimpleHttpRequest jwksRequest = simpleHttp.doGet(jwksUri).header(HttpHeaders.ACCEPT, "application/jwk-set+json");
if (token != null) {
Expand Down
Loading
0