Correct handling of claim entities

Signed-off-by: Andy Caruso <macaruso@gmail.com>
This commit is contained in:
Andy Caruso
2022-03-29 09:12:22 -07:00
committed by blam
parent ab93c04c67
commit cbe119efa6
2 changed files with 16 additions and 1 deletions
@@ -143,6 +143,21 @@ describe('IdentityClient', () => {
});
});
it('should decode claims correctly', async () => {
const token = await factory.issueToken({
claims: { sub: 'foo', ent: ['entity1', 'entity2'] },
});
const response = await client.authenticate(token);
expect(response).toEqual({
token: token,
identity: {
type: 'user',
userEntityRef: 'foo',
ownershipEntityRefs: ['entity1', 'entity2'],
},
});
});
it('should throw on incorrect issuer', async () => {
const hackerFactory = new FakeTokenFactory({
issuer: 'hacker',
+1 -1
View File
@@ -95,7 +95,7 @@ export class IdentityClient {
type: 'user',
userEntityRef: decoded.payload.sub,
ownershipEntityRefs: decoded.payload.ent
? [decoded.payload.ent as string]
? (decoded.payload.ent as string[])
: [],
},
};