@backstage/plugin-kubernetes 0.6.5-next.2 → 0.6.5-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +47 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/plugin-kubernetes
|
|
2
2
|
|
|
3
|
+
## 0.6.5-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 447e060872: Add support for 'oidc' as authProvider for kubernetes authentication
|
|
8
|
+
and adds optional 'oidcTokenProvider' config value. This will allow
|
|
9
|
+
users to authenticate to kubernetes cluster using id tokens obtained
|
|
10
|
+
from the configured auth provider in their backstage instance.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/plugin-kubernetes-common@0.2.10-next.1
|
|
13
|
+
- @backstage/core-components@0.9.4-next.2
|
|
14
|
+
|
|
3
15
|
## 0.6.5-next.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
3
|
-
import { DiscoveryApi, IdentityApi, OAuthApi } from '@backstage/core-plugin-api';
|
|
3
|
+
import { DiscoveryApi, IdentityApi, OAuthApi, OpenIdConnectApi } from '@backstage/core-plugin-api';
|
|
4
4
|
import { Entity } from '@backstage/catalog-model';
|
|
5
5
|
import { KubernetesRequestBody, ObjectsByEntityResponse, ClusterObjects, ClientPodStatus, ClusterAttributes } from '@backstage/plugin-kubernetes-common';
|
|
6
6
|
import { JsonObject } from '@backstage/types';
|
|
@@ -22,6 +22,7 @@ interface KubernetesApi {
|
|
|
22
22
|
getClusters(): Promise<{
|
|
23
23
|
name: string;
|
|
24
24
|
authProvider: string;
|
|
25
|
+
oidcTokenProvider?: string | undefined;
|
|
25
26
|
}[]>;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -53,6 +54,9 @@ declare class KubernetesAuthProviders implements KubernetesAuthProvidersApi {
|
|
|
53
54
|
private readonly kubernetesAuthProviderMap;
|
|
54
55
|
constructor(options: {
|
|
55
56
|
googleAuthApi: OAuthApi;
|
|
57
|
+
oidcProviders?: {
|
|
58
|
+
[key: string]: OpenIdConnectApi;
|
|
59
|
+
};
|
|
56
60
|
});
|
|
57
61
|
decorateRequestBodyForAuth(authProvider: string, requestBody: KubernetesRequestBody): Promise<KubernetesRequestBody>;
|
|
58
62
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, googleAuthApiRef, createRoutableExtension, useApi } from '@backstage/core-plugin-api';
|
|
1
|
+
import { createApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, googleAuthApiRef, microsoftAuthApiRef, oktaAuthApiRef, oneloginAuthApiRef, createRoutableExtension, useApi } from '@backstage/core-plugin-api';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { Fragment, useState, useEffect, useContext } from 'react';
|
|
4
4
|
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
@@ -114,6 +114,24 @@ class AzureKubernetesAuthProvider {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
class OidcKubernetesAuthProvider {
|
|
118
|
+
constructor(providerName, authProvider) {
|
|
119
|
+
this.providerName = providerName;
|
|
120
|
+
this.authProvider = authProvider;
|
|
121
|
+
}
|
|
122
|
+
async decorateRequestBodyForAuth(requestBody) {
|
|
123
|
+
const authToken = await this.authProvider.getIdToken();
|
|
124
|
+
const auth = { ...requestBody.auth };
|
|
125
|
+
if (auth.oidc) {
|
|
126
|
+
auth.oidc[this.providerName] = authToken;
|
|
127
|
+
} else {
|
|
128
|
+
auth.oidc = { [this.providerName]: authToken };
|
|
129
|
+
}
|
|
130
|
+
requestBody.auth = auth;
|
|
131
|
+
return requestBody;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
117
135
|
class KubernetesAuthProviders {
|
|
118
136
|
constructor(options) {
|
|
119
137
|
this.kubernetesAuthProviderMap = /* @__PURE__ */ new Map();
|
|
@@ -122,12 +140,20 @@ class KubernetesAuthProviders {
|
|
|
122
140
|
this.kubernetesAuthProviderMap.set("googleServiceAccount", new GoogleServiceAccountAuthProvider());
|
|
123
141
|
this.kubernetesAuthProviderMap.set("aws", new AwsKubernetesAuthProvider());
|
|
124
142
|
this.kubernetesAuthProviderMap.set("azure", new AzureKubernetesAuthProvider());
|
|
143
|
+
if (options.oidcProviders) {
|
|
144
|
+
Object.keys(options.oidcProviders).forEach((provider) => {
|
|
145
|
+
this.kubernetesAuthProviderMap.set(`oidc.${provider}`, new OidcKubernetesAuthProvider(provider, options.oidcProviders[provider]));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
125
148
|
}
|
|
126
149
|
async decorateRequestBodyForAuth(authProvider, requestBody) {
|
|
127
150
|
const kubernetesAuthProvider = this.kubernetesAuthProviderMap.get(authProvider);
|
|
128
151
|
if (kubernetesAuthProvider) {
|
|
129
152
|
return await kubernetesAuthProvider.decorateRequestBodyForAuth(requestBody);
|
|
130
153
|
}
|
|
154
|
+
if (authProvider.startsWith("oidc.")) {
|
|
155
|
+
throw new Error(`KubernetesAuthProviders has no oidcProvider configured for ${authProvider}`);
|
|
156
|
+
}
|
|
131
157
|
throw new Error(`authProvider "${authProvider}" has no KubernetesAuthProvider defined for it`);
|
|
132
158
|
}
|
|
133
159
|
}
|
|
@@ -148,9 +174,25 @@ const kubernetesPlugin = createPlugin({
|
|
|
148
174
|
}),
|
|
149
175
|
createApiFactory({
|
|
150
176
|
api: kubernetesAuthProvidersApiRef,
|
|
151
|
-
deps: {
|
|
152
|
-
|
|
153
|
-
|
|
177
|
+
deps: {
|
|
178
|
+
googleAuthApi: googleAuthApiRef,
|
|
179
|
+
microsoftAuthApi: microsoftAuthApiRef,
|
|
180
|
+
oktaAuthApi: oktaAuthApiRef,
|
|
181
|
+
oneloginAuthApi: oneloginAuthApiRef
|
|
182
|
+
},
|
|
183
|
+
factory: ({
|
|
184
|
+
googleAuthApi,
|
|
185
|
+
microsoftAuthApi,
|
|
186
|
+
oktaAuthApi,
|
|
187
|
+
oneloginAuthApi
|
|
188
|
+
}) => {
|
|
189
|
+
const oidcProviders = {
|
|
190
|
+
google: googleAuthApi,
|
|
191
|
+
microsoft: microsoftAuthApi,
|
|
192
|
+
okta: oktaAuthApi,
|
|
193
|
+
onelogin: oneloginAuthApi
|
|
194
|
+
};
|
|
195
|
+
return new KubernetesAuthProviders({ googleAuthApi, oidcProviders });
|
|
154
196
|
}
|
|
155
197
|
})
|
|
156
198
|
],
|
|
@@ -589,7 +631,7 @@ const useKubernetesObjects = (entity, intervalMs = 1e4) => {
|
|
|
589
631
|
return;
|
|
590
632
|
}
|
|
591
633
|
const authProviders = [
|
|
592
|
-
...new Set(clusters.map((c) => c.authProvider))
|
|
634
|
+
...new Set(clusters.map((c) => `${c.authProvider}${c.oidcTokenProvider ? `.${c.oidcTokenProvider}` : ""}`))
|
|
593
635
|
];
|
|
594
636
|
let requestBody = {
|
|
595
637
|
entity
|