replace noop with distinct strategies
one for serviceaccount and one for anonymous (used by localKubectlProxy) Signed-off-by: Jamie Klassen <jklassen@vmware.com>
This commit is contained in:
@@ -32,6 +32,14 @@ export class AksStrategy implements AuthenticationStrategy {
|
||||
validate(_: AuthMetadata): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export class AnonymousStrategy implements AuthenticationStrategy {
|
||||
// (undocumented)
|
||||
getCredential(): Promise<KubernetesCredential>;
|
||||
// (undocumented)
|
||||
validate(): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface AuthenticationStrategy {
|
||||
// (undocumented)
|
||||
@@ -383,14 +391,6 @@ export interface KubernetesServiceLocator {
|
||||
}>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export class NoopStrategy implements AuthenticationStrategy {
|
||||
// (undocumented)
|
||||
getCredential(): Promise<KubernetesCredential>;
|
||||
// (undocumented)
|
||||
validate(): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ObjectFetchParams {
|
||||
// (undocumented)
|
||||
@@ -451,6 +451,14 @@ export interface RouterOptions {
|
||||
permissions: PermissionEvaluator;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export class ServiceAccountStrategy implements AuthenticationStrategy {
|
||||
// (undocumented)
|
||||
getCredential(clusterDetails: ClusterDetails): Promise<KubernetesCredential>;
|
||||
// (undocumented)
|
||||
validate(): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type ServiceLocatorMethod = 'multiTenant' | 'http';
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2020 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AuthenticationStrategy, KubernetesCredential } from './types';
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class AnonymousStrategy implements AuthenticationStrategy {
|
||||
public async getCredential(): Promise<KubernetesCredential> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public validate() {}
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ import { ClusterDetails } from '../types/types';
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class NoopStrategy implements AuthenticationStrategy {
|
||||
export class ServiceAccountStrategy implements AuthenticationStrategy {
|
||||
public async getCredential(
|
||||
clusterDetails: ClusterDetails,
|
||||
): Promise<KubernetesCredential> {
|
||||
@@ -15,11 +15,12 @@
|
||||
*/
|
||||
|
||||
export * from './AksStrategy';
|
||||
export * from './AnonymousStrategy';
|
||||
export * from './AwsIamStrategy';
|
||||
export * from './AzureIdentityStrategy';
|
||||
export * from './GoogleStrategy';
|
||||
export * from './GoogleServiceAccountStrategy';
|
||||
export * from './DispatchStrategy';
|
||||
export * from './NoopStrategy';
|
||||
export * from './ServiceAccountStrategy';
|
||||
export * from './OidcStrategy';
|
||||
export * from './types';
|
||||
|
||||
@@ -30,9 +30,10 @@ import { Logger } from 'winston';
|
||||
import { getCombinedClusterSupplier } from '../cluster-locator';
|
||||
import {
|
||||
AuthenticationStrategy,
|
||||
AnonymousStrategy,
|
||||
DispatchStrategy,
|
||||
GoogleStrategy,
|
||||
NoopStrategy,
|
||||
ServiceAccountStrategy,
|
||||
AwsIamStrategy,
|
||||
GoogleServiceAccountStrategy,
|
||||
AzureIdentityStrategy,
|
||||
@@ -369,9 +370,9 @@ export class KubernetesBuilder {
|
||||
azure: new AzureIdentityStrategy(this.env.logger),
|
||||
google: new GoogleStrategy(),
|
||||
googleServiceAccount: new GoogleServiceAccountStrategy(),
|
||||
localKubectlProxy: new NoopStrategy(),
|
||||
localKubectlProxy: new AnonymousStrategy(),
|
||||
oidc: new OidcStrategy(),
|
||||
serviceAccount: new NoopStrategy(),
|
||||
serviceAccount: new ServiceAccountStrategy(),
|
||||
};
|
||||
return this.authStrategyMap;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import request from 'supertest';
|
||||
import { AddressInfo, WebSocket, WebSocketServer } from 'ws';
|
||||
|
||||
import { LocalKubectlProxyClusterLocator } from '../cluster-locator/LocalKubectlProxyLocator';
|
||||
import { AuthenticationStrategy, NoopStrategy } from '../auth';
|
||||
import { AuthenticationStrategy, AnonymousStrategy } from '../auth';
|
||||
import { ClusterDetails, KubernetesClustersSupplier } from '../types/types';
|
||||
import {
|
||||
APPLICATION_JSON,
|
||||
@@ -495,7 +495,7 @@ describe('KubernetesProxy', () => {
|
||||
proxy = new KubernetesProxy({
|
||||
logger: getVoidLogger(),
|
||||
clusterSupplier: new LocalKubectlProxyClusterLocator(),
|
||||
authStrategy: new NoopStrategy(),
|
||||
authStrategy: new AnonymousStrategy(),
|
||||
});
|
||||
|
||||
worker.use(
|
||||
|
||||
Reference in New Issue
Block a user