Skip to content

Commit

Permalink
Check status code of OIDC discovery response (#3707)
Browse files Browse the repository at this point in the history
* Check status code of OIDC discovery endpoint

* Run update-codegen.sh

* Only allow 200 status code on OIDC discovery endpoint
  • Loading branch information
creydr authored Feb 20, 2024
1 parent ec4fa35 commit 6596c48
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class OIDCDiscoveryConfig {

private static final Logger logger = LoggerFactory.getLogger(TokenVerifier.class);

private static final String OIDC_DISCOVERY_URL = "https://kubernetes.default.svc/.well-known/openid-configuration";

private String issuer;

private JwksVerificationKeyResolver jwksVerificationKeyResolver;
Expand All @@ -58,13 +60,18 @@ public static Future<OIDCDiscoveryConfig> build(Vertx vertx) {
OIDCDiscoveryConfig oidcDiscoveryConfig = new OIDCDiscoveryConfig();

return webClient
.getAbs("https://kubernetes.default.svc/.well-known/openid-configuration")
.getAbs(OIDC_DISCOVERY_URL)
.bearerTokenAuthentication(kubeConfig.getAutoOAuthToken())
.send()
.compose(res -> {
logger.debug("Got raw OIDC discovery info: " + res.bodyAsString());

try {
if (res.statusCode() != 200) {
return Future.failedFuture("Unexpected status (" + res.statusCode()
+ ") on OIDC discovery endpoint: " + res.bodyAsString());
}

ObjectMapper mapper = new ObjectMapper();
OIDCInfo oidcInfo = mapper.readValue(res.bodyAsString(), OIDCInfo.class);

Expand Down

0 comments on commit 6596c48

Please sign in to comment.