Forward authorization header token

This commit is contained in:
Erik Larsson
2021-01-31 01:17:11 +01:00
parent 9729d9e572
commit 987fa8b24f
2 changed files with 3 additions and 7 deletions
+1
View File
@@ -34,6 +34,7 @@
"@backstage/catalog-model": "^0.7.0",
"@backstage/config": "^0.1.2",
"@backstage/integration": "^0.3.1",
"@backstage/plugin-auth-backend": "^0.2.12",
"@gitbeaker/core": "^28.0.2",
"@gitbeaker/node": "^28.0.2",
"@octokit/rest": "^18.0.12",
@@ -15,6 +15,7 @@
*/
import { Config } from '@backstage/config';
import { IdentityClient } from '@backstage/plugin-auth-backend';
import Docker from 'dockerode';
import express from 'express';
import { resolve as resolvePath } from 'path';
@@ -45,11 +46,6 @@ export interface RouterOptions {
entityClient: CatalogEntityClient;
}
// Avoid import of @backstage/core
type BackstageIdentity = {
idToken: string;
};
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
@@ -103,9 +99,8 @@ export async function createRouter(
};
// Forward authorization from client
const user = req.user as BackstageIdentity;
const template = await entityClient.findTemplate(templateName, {
token: user?.idToken,
token: IdentityClient.getBearerToken(req.headers.authorization),
});
const validationResult: ValidatorResult = validate(