backend-app-api: pass expiration key

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2024-03-27 10:31:45 +01:00
parent 1bb21344e2
commit 7231bc2a71
@@ -79,11 +79,13 @@ export class PluginTokenHandler {
delete this.privateKeyPromise;
}
this.keyExpiry = DateTime.utc()
const keyExpiry = DateTime.utc()
.plus({
seconds: this.keyDurationSeconds,
})
.toJSDate();
this.keyExpiry = keyExpiry;
const promise = (async () => {
// This generates a new signing key to be used to sign tokens until the next key rotation
const kid = uuid();
@@ -100,10 +102,10 @@ export class PluginTokenHandler {
// the new one. This also needs to be implemented cross-service though, meaning new services
// that boot up need to be able to grab an existing key to use for signing.
this.logger.info(`Created new signing key ${kid}`);
this.publicKeyStore.addKey({
await this.publicKeyStore.addKey({
id: kid,
key: publicKey,
expiry: /* TODO */ this.keyExpiry,
expiresAt: keyExpiry,
});
// At this point we are allowed to start using the new key