Correct handling of claim entities
Signed-off-by: Andy Caruso <macaruso@gmail.com>
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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[])
|
||||
: [],
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user