Merge pull request #11132 from backstage/rugvip/auth-fix

auth-backend: fix ent claim being dropped
This commit is contained in:
Ben Lambert
2022-04-28 10:09:47 +02:00
committed by GitHub
3 changed files with 10 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend': patch
---
Fixed a bug that was introduced in `0.13.1-next.0` which caused the `ent` claim of issued tokens to be dropped.
@@ -47,7 +47,9 @@ describe('TokenFactory', () => {
});
await expect(factory.listPublicKeys()).resolves.toEqual({ keys: [] });
const token = await factory.issueToken({ claims: { sub: entityRef } });
const token = await factory.issueToken({
claims: { sub: entityRef, ent: [entityRef] },
});
const { keys } = await factory.listPublicKeys();
const keyStore = createLocalJWKSet({ keys: keys });
@@ -57,6 +59,7 @@ describe('TokenFactory', () => {
iss: 'my-issuer',
aud: 'backstage',
sub: entityRef,
ent: [entityRef],
iat: expect.any(Number),
exp: expect.any(Number),
});
@@ -89,7 +89,7 @@ export class TokenFactory implements TokenIssuer {
throw new AuthenticationError('No algorithm was provided in the key');
}
return new SignJWT({ iss, sub, aud, iat, exp })
return new SignJWT({ iss, sub, ent, aud, iat, exp })
.setProtectedHeader({ alg: key.alg, kid: key.kid })
.setIssuer(iss)
.setAudience(aud)