From 5ca0b86b88d68672133af75343bcb6e91fa0b220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 13 Jun 2022 14:50:23 +0200 Subject: [PATCH] always create a keystore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/polite-jokes-matter.md | 5 +++++ plugins/auth-node/src/IdentityClient.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/polite-jokes-matter.md diff --git a/.changeset/polite-jokes-matter.md b/.changeset/polite-jokes-matter.md new file mode 100644 index 0000000000..d317b79a7d --- /dev/null +++ b/.changeset/polite-jokes-matter.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-node': patch +--- + +Address corner cases where the key store was not being created at startup diff --git a/plugins/auth-node/src/IdentityClient.ts b/plugins/auth-node/src/IdentityClient.ts index 3799222447..0773d22c26 100644 --- a/plugins/auth-node/src/IdentityClient.ts +++ b/plugins/auth-node/src/IdentityClient.ts @@ -141,7 +141,7 @@ export class IdentityClient { // Add a small margin in case clocks are out of sync const issuedAfterLastRefresh = payload?.iat && payload.iat > this.keyStoreUpdated - CLOCK_MARGIN_S; - if (!keyStoreHasKey && issuedAfterLastRefresh) { + if (!this.keyStore || (!keyStoreHasKey && issuedAfterLastRefresh)) { const url = await this.discovery.getBaseUrl('auth'); const endpoint = new URL(`${url}/.well-known/jwks.json`); this.keyStore = createRemoteJWKSet(endpoint);