backend-common: remove isSecure property in favour of a property on the NoopServerTokenManager
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -502,8 +502,6 @@ export class ServerTokenManager implements TokenManager {
|
||||
token: string;
|
||||
}>;
|
||||
// (undocumented)
|
||||
readonly isSecure: boolean;
|
||||
// (undocumented)
|
||||
static noop(): TokenManager;
|
||||
}
|
||||
|
||||
@@ -574,7 +572,6 @@ export interface TokenManager {
|
||||
getToken: () => Promise<{
|
||||
token: string;
|
||||
}>;
|
||||
isSecure: boolean;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
@@ -21,7 +21,7 @@ import { TokenManager } from './types';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
class NoopTokenManager implements TokenManager {
|
||||
public readonly isSecure: boolean = false;
|
||||
public readonly isInsecureServerTokenManager: boolean = true;
|
||||
|
||||
async getToken() {
|
||||
return { token: '' };
|
||||
@@ -39,7 +39,6 @@ class NoopTokenManager implements TokenManager {
|
||||
export class ServerTokenManager implements TokenManager {
|
||||
private readonly verificationKeys: JWKS.KeyStore;
|
||||
private readonly signingKey: JWK.Key;
|
||||
public readonly isSecure: boolean = true;
|
||||
|
||||
static noop(): TokenManager {
|
||||
return new NoopTokenManager();
|
||||
|
||||
@@ -20,12 +20,6 @@
|
||||
* @public
|
||||
*/
|
||||
export interface TokenManager {
|
||||
/**
|
||||
* This property should be true when the token manager is expected to only
|
||||
* authenticate tokens created by itself, or an equivalently-constructed
|
||||
* instance.
|
||||
*/
|
||||
isSecure: boolean;
|
||||
getToken: () => Promise<{ token: string }>;
|
||||
authenticate: (token: string) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ describe('DefaultCatalogCollator', () => {
|
||||
getExternalBaseUrl: jest.fn(),
|
||||
};
|
||||
mockTokenManager = {
|
||||
isSecure: true,
|
||||
getToken: jest.fn().mockResolvedValue({ token: '' }),
|
||||
authenticate: jest.fn(),
|
||||
};
|
||||
|
||||
@@ -51,7 +51,10 @@ export class ServerPermissionClient implements PermissionAuthorizer {
|
||||
const permissionEnabled =
|
||||
config.getOptionalBoolean('permission.enabled') ?? false;
|
||||
|
||||
if (permissionEnabled && !tokenManager.isSecure) {
|
||||
if (
|
||||
permissionEnabled &&
|
||||
(tokenManager as any).isInsecureServerTokenManager
|
||||
) {
|
||||
throw new Error(
|
||||
'You must configure at least one key in backend.auth.keys if permissions are enabled.',
|
||||
);
|
||||
|
||||
@@ -99,7 +99,6 @@ describe('DefaultTechDocsCollator with legacyPathCasing configuration', () => {
|
||||
getExternalBaseUrl: jest.fn(),
|
||||
};
|
||||
mockTokenManager = {
|
||||
isSecure: true,
|
||||
getToken: jest.fn().mockResolvedValue({ token: '' }),
|
||||
authenticate: jest.fn(),
|
||||
};
|
||||
@@ -166,7 +165,6 @@ describe('DefaultTechDocsCollator', () => {
|
||||
getExternalBaseUrl: jest.fn(),
|
||||
};
|
||||
mockTokenManager = {
|
||||
isSecure: true,
|
||||
getToken: jest.fn().mockResolvedValue({ token: '' }),
|
||||
authenticate: jest.fn(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user