always create a keystore

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-06-13 14:50:23 +02:00
parent 6659e90873
commit 5ca0b86b88
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-node': patch
---
Address corner cases where the key store was not being created at startup
+1 -1
View File
@@ -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);