Change AuthIdentityTokenManager to ServerTokenManager

Co-authored-by: Joe Porpeglia <joeporpeglia@users.noreply.github.com>
Co-authored-by: Tim Hansen <timbonicus@gmail.com>
Signed-off-by: Nataliya Issayeva <nissayeva@users.noreply.github.com>
This commit is contained in:
Nataliya Issayeva
2021-11-09 17:57:03 -05:00
parent fa6a9b797f
commit b38d77f4f0
12 changed files with 109 additions and 161 deletions
+6 -3
View File
@@ -33,7 +33,7 @@ import {
SingleHostDiscovery,
UrlReaders,
useHotMemoize,
AuthIdentityTokenManager,
ServerTokenManager,
IdentityClient,
} from '@backstage/backend-common';
import { Config } from '@backstage/config';
@@ -66,7 +66,7 @@ function makeCreateEnv(config: Config) {
const root = getRootLogger();
const reader = UrlReaders.default({ logger: root, config });
const discovery = SingleHostDiscovery.fromConfig(config);
const tokenManager = new AuthIdentityTokenManager(discovery, config);
const tokenManager = new ServerTokenManager(config);
root.info(`Created UrlReader ${reader}`);
@@ -158,7 +158,10 @@ async function main() {
IdentityClient.getBearerToken(req.headers.authorization) ||
req.cookies.token;
await authEnv.tokenManager.validateToken(token);
const isServerToken = await authEnv.tokenManager.isServerToken(token);
if (!isServerToken) {
await identity.authenticate(token);
}
if (!req.headers.authorization) {
// Authorization header may be forwarded by plugin requests
+2 -2
View File
@@ -17,10 +17,10 @@
import { Logger } from 'winston';
import { Config } from '@backstage/config';
import {
AuthIdentityTokenManager,
PluginCacheManager,
PluginDatabaseManager,
PluginEndpointDiscovery,
TokenManager,
UrlReader,
} from '@backstage/backend-common';
@@ -31,5 +31,5 @@ export type PluginEnvironment = {
config: Config;
reader: UrlReader;
discovery: PluginEndpointDiscovery;
tokenManager: AuthIdentityTokenManager;
tokenManager: TokenManager;
};