@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes-backend': minor
|
||||
---
|
||||
|
||||
**BREAKING**: `KubernetesProxy` now requires the `DiscoveryService` to be passed to the constuctor
|
||||
@@ -191,7 +191,7 @@ export class KubernetesBuilder {
|
||||
protected buildProxy(
|
||||
logger: Logger,
|
||||
clusterSupplier: KubernetesClustersSupplier_2,
|
||||
httpAuth: HttpAuthService,
|
||||
discovery: DiscoveryService,
|
||||
): KubernetesProxy;
|
||||
// (undocumented)
|
||||
protected buildRouter(
|
||||
@@ -241,7 +241,7 @@ export class KubernetesBuilder {
|
||||
protected getProxy(
|
||||
logger: Logger,
|
||||
clusterSupplier: KubernetesClustersSupplier_2,
|
||||
httpAuth: HttpAuthService,
|
||||
discovery: DiscoveryService,
|
||||
): KubernetesProxy;
|
||||
// (undocumented)
|
||||
protected getServiceLocator(): KubernetesServiceLocator_2;
|
||||
@@ -348,7 +348,7 @@ export type KubernetesProxyOptions = {
|
||||
logger: Logger;
|
||||
clusterSupplier: KubernetesClustersSupplier;
|
||||
authStrategy: AuthenticationStrategy;
|
||||
httpAuth: HttpAuthService;
|
||||
discovery: DiscoveryService;
|
||||
};
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
|
||||
@@ -157,7 +157,7 @@ export class KubernetesBuilder {
|
||||
|
||||
const authStrategyMap = this.getAuthStrategyMap();
|
||||
|
||||
const proxy = this.getProxy(logger, clusterSupplier, httpAuth);
|
||||
const proxy = this.getProxy(logger, clusterSupplier, this.env.discovery);
|
||||
|
||||
const serviceLocator = this.getServiceLocator();
|
||||
|
||||
@@ -350,7 +350,7 @@ export class KubernetesBuilder {
|
||||
protected buildProxy(
|
||||
logger: Logger,
|
||||
clusterSupplier: KubernetesClustersSupplier,
|
||||
httpAuth: HttpAuthService,
|
||||
discovery: DiscoveryService,
|
||||
): KubernetesProxy {
|
||||
const authStrategyMap = this.getAuthStrategyMap();
|
||||
const authStrategy = new DispatchStrategy({
|
||||
@@ -360,7 +360,7 @@ export class KubernetesBuilder {
|
||||
logger,
|
||||
clusterSupplier,
|
||||
authStrategy,
|
||||
httpAuth,
|
||||
discovery,
|
||||
});
|
||||
return this.proxy;
|
||||
}
|
||||
@@ -535,9 +535,9 @@ export class KubernetesBuilder {
|
||||
protected getProxy(
|
||||
logger: Logger,
|
||||
clusterSupplier: KubernetesClustersSupplier,
|
||||
httpAuth: HttpAuthService,
|
||||
discovery: DiscoveryService,
|
||||
) {
|
||||
return this.proxy ?? this.buildProxy(logger, clusterSupplier, httpAuth);
|
||||
return this.proxy ?? this.buildProxy(logger, clusterSupplier, discovery);
|
||||
}
|
||||
|
||||
protected getAuthStrategyMap() {
|
||||
|
||||
@@ -57,7 +57,7 @@ import {
|
||||
import type { Request } from 'express';
|
||||
import {
|
||||
BackstageCredentials,
|
||||
HttpAuthService,
|
||||
DiscoveryService,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
|
||||
const mockCertDir = createMockDirectory({
|
||||
@@ -84,9 +84,9 @@ describe('KubernetesProxy', () => {
|
||||
authorizeConditional: jest.fn(),
|
||||
};
|
||||
|
||||
const mockHttpAuth: jest.Mocked<HttpAuthService> = {
|
||||
credentials: jest.fn(),
|
||||
issueUserCookie: jest.fn(),
|
||||
const mockDisocveryApi: jest.Mocked<DiscoveryService> = {
|
||||
getBaseUrl: jest.fn(),
|
||||
getExternalBaseUrl: jest.fn(),
|
||||
};
|
||||
|
||||
setupRequestMockHandlers(worker);
|
||||
@@ -162,7 +162,7 @@ describe('KubernetesProxy', () => {
|
||||
logger,
|
||||
clusterSupplier,
|
||||
authStrategy,
|
||||
httpAuth: mockHttpAuth,
|
||||
discovery: mockDisocveryApi,
|
||||
});
|
||||
permissionApi.authorize.mockResolvedValue([
|
||||
{ result: AuthorizeResult.ALLOW },
|
||||
@@ -552,7 +552,7 @@ describe('KubernetesProxy', () => {
|
||||
logger: getVoidLogger(),
|
||||
clusterSupplier: clusterSupplier,
|
||||
authStrategy: strategy,
|
||||
httpAuth: mockHttpAuth,
|
||||
discovery: mockDisocveryApi,
|
||||
});
|
||||
|
||||
worker.use(
|
||||
@@ -674,7 +674,7 @@ describe('KubernetesProxy', () => {
|
||||
logger: getVoidLogger(),
|
||||
clusterSupplier: new LocalKubectlProxyClusterLocator(),
|
||||
authStrategy: new AnonymousStrategy(),
|
||||
httpAuth: mockHttpAuth,
|
||||
discovery: mockDisocveryApi,
|
||||
});
|
||||
|
||||
worker.use(
|
||||
|
||||
@@ -42,9 +42,11 @@ import { ClusterDetails, KubernetesClustersSupplier } from '../types/types';
|
||||
import type { Request } from 'express';
|
||||
import { IncomingHttpHeaders } from 'http';
|
||||
import {
|
||||
DiscoveryService,
|
||||
HttpAuthService,
|
||||
PermissionsService,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createLegacyAuthAdapters } from '@backstage/backend-common';
|
||||
|
||||
export const APPLICATION_JSON: string = 'application/json';
|
||||
|
||||
@@ -81,7 +83,7 @@ export type KubernetesProxyOptions = {
|
||||
logger: Logger;
|
||||
clusterSupplier: KubernetesClustersSupplier;
|
||||
authStrategy: AuthenticationStrategy;
|
||||
httpAuth: HttpAuthService;
|
||||
discovery: DiscoveryService;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -100,7 +102,7 @@ export class KubernetesProxy {
|
||||
this.logger = options.logger;
|
||||
this.clusterSupplier = options.clusterSupplier;
|
||||
this.authStrategy = options.authStrategy;
|
||||
this.httpAuth = options.httpAuth;
|
||||
this.httpAuth = createLegacyAuthAdapters({ discovery: options.discovery });
|
||||
}
|
||||
|
||||
public createRequestHandler(
|
||||
|
||||
Reference in New Issue
Block a user