Use backend secret from config
Signed-off-by: Nataliya Issayeva <nissayeva@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,8 @@ app:
|
||||
title: '#backstage'
|
||||
|
||||
backend:
|
||||
auth:
|
||||
secret: ${BACKEND_SECRET}
|
||||
baseUrl: http://localhost:7000
|
||||
listen:
|
||||
port: 7000
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { JWK, JWT } from 'jose';
|
||||
import { Config } from '@backstage/config';
|
||||
import { TokenManager } from './types';
|
||||
import { IdentityClient } from '../identity';
|
||||
import { PluginEndpointDiscovery } from '../discovery';
|
||||
@@ -24,11 +25,13 @@ export class AuthIdentityTokenManager implements TokenManager {
|
||||
private identityClient: IdentityClient;
|
||||
private key: JWK.OctKey;
|
||||
|
||||
constructor(discovery: PluginEndpointDiscovery, secret: string) {
|
||||
constructor(discovery: PluginEndpointDiscovery, config: Config) {
|
||||
this.identityClient = new IdentityClient({
|
||||
discovery: discovery,
|
||||
issuer: 'auth-identity-token-manager',
|
||||
});
|
||||
|
||||
const secret = config.getConfig('backend.auth').getString('secret');
|
||||
this.key = JWK.asKey({ kty: 'oct', k: secret });
|
||||
}
|
||||
|
||||
|
||||
@@ -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, 'secret-tehe');
|
||||
const tokenManager = new AuthIdentityTokenManager(discovery, config);
|
||||
|
||||
root.info(`Created UrlReader ${reader}`);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ function makeCreateEnv(config: Config) {
|
||||
|
||||
const cacheManager = CacheManager.fromConfig(config);
|
||||
const databaseManager = DatabaseManager.fromConfig(config);
|
||||
const tokenManager = new AuthIdentityTokenManager(discovery);
|
||||
const tokenManager = new AuthIdentityTokenManager(discovery, config);
|
||||
|
||||
return (plugin: string): PluginEnvironment => {
|
||||
const logger = root.child({ type: 'plugin', plugin });
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
export { createOidcRouter } from './router';
|
||||
// export { IdentityClient } from './IdentityClient';
|
||||
export { TokenFactory } from './TokenFactory';
|
||||
export { DatabaseKeyStore } from './DatabaseKeyStore';
|
||||
export { MemoryKeyStore } from './MemoryKeyStore';
|
||||
|
||||
Reference in New Issue
Block a user