Skip to content

Commit

Permalink
fix fabric8io#5608 support authentication with certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
qingboooo committed Nov 27, 2023
1 parent c2254c0 commit 83e650c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#### Dependency Upgrade

#### New Features
* Fix #5608 support authentication with certificate

#### _**Note**_: Breaking changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,18 +782,26 @@ private static void mergeKubeConfigAuthProviderConfig(Config config, AuthInfo cu

private static void mergeKubeConfigExecCredential(Config config, ExecConfig exec, File configFile)
throws IOException {
if (exec != null) {
try {
ExecCredential ec = getExecCredentialFromExecConfig(exec, configFile);
if (ec != null && ec.status != null && ec.status.token != null) {
config.setAutoOAuthToken(ec.status.token);
} else {
LOGGER.warn("No token returned");
}
} catch (InterruptedException interruptedException) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable("failure while running exec credential ", interruptedException);
if (exec == null) {
return;
}
try {
ExecCredential ec = getExecCredentialFromExecConfig(exec, configFile);
if (ec == null || ec.status == null) {
LOGGER.warn("The generated exec credential is null or its content is invalid");
return;
}
if (ec.status.token != null) {
config.setAutoOAuthToken(ec.status.token);
} else if (ec.status.clientCertificateData != null && ec.status.clientKeyData != null) {
config.setClientCertData(ec.status.clientCertificateData);
config.setClientKeyData(ec.status.clientKeyData);
} else {
LOGGER.warn("Both token and certificate are unavailable");
}
} catch (InterruptedException interruptedException) {
Thread.currentThread().interrupt();
throw KubernetesClientException.launderThrowable("failure while running exec credential ", interruptedException);
}
}

Expand Down Expand Up @@ -898,6 +906,8 @@ public static final class ExecCredentialSpec {
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class ExecCredentialStatus {
public String token;
public String clientCertificateData;
public String clientKeyData;
// TODO clientCertificateData, clientKeyData, expirationTimestamp
}

Expand Down

0 comments on commit 83e650c

Please sign in to comment.