Address comments on pr for k8s oidc authProvider
Signed-off-by: Daniel Bravo <dbravo@vmware.com>
This commit is contained in:
+6
-1
@@ -52,7 +52,12 @@ export interface Config {
|
||||
/** @visibility secret */
|
||||
serviceAccountToken?: string;
|
||||
/** @visibility frontend */
|
||||
authProvider: 'aws' | 'google' | 'serviceAccount' | 'azure' | 'oidc';
|
||||
authProvider:
|
||||
| 'aws'
|
||||
| 'google'
|
||||
| 'serviceAccount'
|
||||
| 'azure'
|
||||
| 'oidc';
|
||||
/** @visibility frontend */
|
||||
oidcTokenProvider?: string;
|
||||
/** @visibility frontend */
|
||||
|
||||
+3
-1
@@ -38,7 +38,9 @@ describe('OidcKubernetesAuthTranslator tests', () => {
|
||||
...baseClusterDetails,
|
||||
},
|
||||
{
|
||||
oidc: { okta: 'fakeToken' },
|
||||
auth: {
|
||||
oidc: { okta: 'fakeToken' },
|
||||
},
|
||||
entity,
|
||||
},
|
||||
);
|
||||
|
||||
+2
-1
@@ -36,7 +36,8 @@ export class OidcKubernetesAuthTranslator implements KubernetesAuthTranslator {
|
||||
);
|
||||
}
|
||||
|
||||
const authToken: string | undefined = requestBody.oidc?.[oidcTokenProvider];
|
||||
const authToken: string | undefined =
|
||||
requestBody.auth?.oidc?.[oidcTokenProvider];
|
||||
|
||||
if (authToken) {
|
||||
clusterDetailsWithAuthToken.serviceAccountToken = authToken;
|
||||
|
||||
@@ -194,14 +194,13 @@ export interface KubernetesFetchError {
|
||||
export interface KubernetesRequestBody {
|
||||
// (undocumented)
|
||||
auth?: {
|
||||
google: string;
|
||||
google?: string;
|
||||
oidc?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
};
|
||||
// (undocumented)
|
||||
entity: Entity;
|
||||
// (undocumented)
|
||||
oidc?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ObjectsByEntityResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
||||
@@ -30,10 +30,10 @@ import { Entity } from '@backstage/catalog-model';
|
||||
|
||||
export interface KubernetesRequestBody {
|
||||
auth?: {
|
||||
google: string;
|
||||
};
|
||||
oidc?: {
|
||||
[key: string]: string;
|
||||
google?: string;
|
||||
oidc?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
};
|
||||
entity: Entity;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('KubernetesAuthProviders tests', () => {
|
||||
requestBody,
|
||||
);
|
||||
|
||||
expect(details.oidc?.okta).toBe('oktaToken');
|
||||
expect(details.auth?.oidc?.okta).toBe('oktaToken');
|
||||
});
|
||||
|
||||
it('returns error for unknown authProvider', async () => {
|
||||
|
||||
@@ -31,11 +31,13 @@ export class OidcKubernetesAuthProvider implements KubernetesAuthProvider {
|
||||
requestBody: KubernetesRequestBody,
|
||||
): Promise<KubernetesRequestBody> {
|
||||
const authToken: string = await this.authProvider.getIdToken();
|
||||
if ('oidc' in requestBody) {
|
||||
requestBody.oidc![this.providerName] = authToken;
|
||||
const auth = { ...requestBody.auth };
|
||||
if (auth.oidc) {
|
||||
auth.oidc[this.providerName] = authToken;
|
||||
} else {
|
||||
requestBody.oidc = { [this.providerName]: authToken };
|
||||
auth.oidc = { [this.providerName]: authToken };
|
||||
}
|
||||
requestBody.auth = auth;
|
||||
return requestBody;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user