Creating extension point for kubernetesAuthStrategy

Signed-off-by: Andres Mauricio Gomez P <andmagom@outlook.com>
This commit is contained in:
Andres Mauricio Gomez P
2023-11-23 10:44:44 -05:00
parent 6010564860
commit 49e6285275
9 changed files with 107 additions and 49 deletions
+20
View File
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import { createExtensionPoint } from '@backstage/backend-plugin-api';
import { AuthenticationStrategy } from '@backstage/plugin-kubernetes-node';
import { KubernetesClustersSupplier } from '@backstage/plugin-kubernetes-node';
import { KubernetesObjectsProvider } from '@backstage/plugin-kubernetes-node';
@@ -54,3 +55,22 @@ export const kubernetesClusterSupplierExtensionPoint =
createExtensionPoint<KubernetesClusterSupplierExtensionPoint>({
id: 'kubernetes.cluster-supplier',
});
/**
* The interface for {@link kubernetesAuthStrategyExtensionPoint}.
*
* @public
*/
export interface KubernetesAuthStrategyExtensionPoint {
addAuthStrategy(key: string, strategy: AuthenticationStrategy): void;
}
/**
* An extension point the exposes the ability to add an Auth Strategy.
*
* @public
*/
export const kubernetesAuthStrategyExtensionPoint =
createExtensionPoint<KubernetesAuthStrategyExtensionPoint>({
id: 'kubernetes.auth-strategy',
});
+2
View File
@@ -34,6 +34,8 @@ export {
type KubernetesObjectsProviderExtensionPoint,
kubernetesClusterSupplierExtensionPoint,
type KubernetesClusterSupplierExtensionPoint,
kubernetesAuthStrategyExtensionPoint,
type KubernetesAuthStrategyExtensionPoint,
} from './extensions';
export * from './types';
@@ -130,3 +130,23 @@ export interface KubernetesClustersSupplier {
*/
getClusters(): Promise<ClusterDetails[]>;
}
/**
* Authentication data used to make a request to Kubernetes
* @public
*/
export type KubernetesCredential =
| { type: 'bearer token'; token: string }
| { type: 'anonymous' };
/**
*
* @public
*/
export interface AuthenticationStrategy {
getCredential(
clusterDetails: ClusterDetails,
authConfig: KubernetesRequestAuth,
): Promise<KubernetesCredential>;
validateCluster(authMetadata: AuthMetadata): Error[];
}