From 9c4e5cdee9d343e6f660a86d6978a29362e10fd6 Mon Sep 17 00:00:00 2001 From: Fabio Torchetti Date: Thu, 23 Jun 2022 13:08:05 -0500 Subject: [PATCH 1/6] Allow specifying JWT token key algorithm Signed-off-by: Fabio Torchetti --- plugins/auth-backend/src/service/router.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 50577ece53..ecd7f725a6 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -44,6 +44,7 @@ export interface RouterOptions { config: Config; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; + tokenKeyAlgorithm?: string; providerFactories?: ProviderFactories; } @@ -56,6 +57,7 @@ export async function createRouter( discovery, database, tokenManager, + tokenKeyAlgorithm, providerFactories, } = options; const router = Router(); @@ -71,6 +73,7 @@ export async function createRouter( keyStore, keyDurationSeconds, logger: logger.child({ component: 'token-factory' }), + algorithm: tokenKeyAlgorithm, }); const catalogApi = new CatalogClient({ discoveryApi: discovery }); From b1c7792e6a2c268edf2770895329c7d056e3642c Mon Sep 17 00:00:00 2001 From: Fabio Torchetti Date: Thu, 23 Jun 2022 13:14:46 -0500 Subject: [PATCH 2/6] Add documentation for new option Signed-off-by: Fabio Torchetti --- plugins/auth-backend/src/service/router.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index ecd7f725a6..2f78f68d7d 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -44,6 +44,14 @@ export interface RouterOptions { config: Config; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; + /** + * The algorithm to be used when signing the JWT token. + * + * @defaultValue `ES256` + * + * @remarks + * This is passed to {@link TokenFactory| the token factory}. + */ tokenKeyAlgorithm?: string; providerFactories?: ProviderFactories; } From c7358cdbc5f1fffd862ef966088a06144a2e5792 Mon Sep 17 00:00:00 2001 From: Fabio Torchetti Date: Thu, 23 Jun 2022 14:29:18 -0500 Subject: [PATCH 3/6] Remove docs for the moment Signed-off-by: Fabio Torchetti --- plugins/auth-backend/api-report.md | 2 ++ plugins/auth-backend/src/service/router.ts | 8 -------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 9e567cc6ab..96ca640479 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -650,6 +650,8 @@ export interface RouterOptions { // (undocumented) providerFactories?: ProviderFactories; // (undocumented) + tokenKeyAlgorithm?: string; + // (undocumented) tokenManager: TokenManager; } diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index 2f78f68d7d..ecd7f725a6 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -44,14 +44,6 @@ export interface RouterOptions { config: Config; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; - /** - * The algorithm to be used when signing the JWT token. - * - * @defaultValue `ES256` - * - * @remarks - * This is passed to {@link TokenFactory| the token factory}. - */ tokenKeyAlgorithm?: string; providerFactories?: ProviderFactories; } From f2cf79d62e2ddda2a981780973c330e4ade68eef Mon Sep 17 00:00:00 2001 From: Fabio Torchetti Date: Thu, 23 Jun 2022 14:34:26 -0500 Subject: [PATCH 4/6] Added changeset Signed-off-by: Fabio Torchetti --- .changeset/plenty-clouds-guess.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/plenty-clouds-guess.md diff --git a/.changeset/plenty-clouds-guess.md b/.changeset/plenty-clouds-guess.md new file mode 100644 index 0000000000..9ef7d00463 --- /dev/null +++ b/.changeset/plenty-clouds-guess.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': minor +--- + +Added an option for the auth backend router to select the algorithm for the JWT token signing keys From 61edb857042f9006404baf2616632a2e2116030d Mon Sep 17 00:00:00 2001 From: Fabio Torchetti Date: Mon, 27 Jun 2022 10:07:59 -0500 Subject: [PATCH 5/6] Naming chnage; fix release size Signed-off-by: Fabio Torchetti --- .changeset/plenty-clouds-guess.md | 2 +- plugins/auth-backend/src/service/router.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.changeset/plenty-clouds-guess.md b/.changeset/plenty-clouds-guess.md index 9ef7d00463..cc56bd604d 100644 --- a/.changeset/plenty-clouds-guess.md +++ b/.changeset/plenty-clouds-guess.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-auth-backend': minor +'@backstage/plugin-auth-backend': patch --- Added an option for the auth backend router to select the algorithm for the JWT token signing keys diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index ecd7f725a6..2232eeaa81 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -44,7 +44,7 @@ export interface RouterOptions { config: Config; discovery: PluginEndpointDiscovery; tokenManager: TokenManager; - tokenKeyAlgorithm?: string; + tokenFactoryAlgorithm?: string; providerFactories?: ProviderFactories; } @@ -57,7 +57,7 @@ export async function createRouter( discovery, database, tokenManager, - tokenKeyAlgorithm, + tokenFactoryAlgorithm, providerFactories, } = options; const router = Router(); @@ -73,7 +73,7 @@ export async function createRouter( keyStore, keyDurationSeconds, logger: logger.child({ component: 'token-factory' }), - algorithm: tokenKeyAlgorithm, + algorithm: tokenFactoryAlgorithm, }); const catalogApi = new CatalogClient({ discoveryApi: discovery }); From 2a50ed04e0c0bf134e95fa3481dc182b5c788fe0 Mon Sep 17 00:00:00 2001 From: Fabio Torchetti Date: Mon, 27 Jun 2022 10:42:05 -0500 Subject: [PATCH 6/6] Rebuild docs for api-report.md Signed-off-by: Fabio Torchetti --- plugins/auth-backend/api-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 96ca640479..d216545bd4 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -650,7 +650,7 @@ export interface RouterOptions { // (undocumented) providerFactories?: ProviderFactories; // (undocumented) - tokenKeyAlgorithm?: string; + tokenFactoryAlgorithm?: string; // (undocumented) tokenManager: TokenManager; }