Skip to content

Commit 35a57e3

Browse files
committed
Test registry catalog tokens
Change-type: patch
1 parent 367bca5 commit 35a57e3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/features/registry/registry.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,21 @@ const generateToken = (
558558
audience: string,
559559
access: Access[],
560560
): string => {
561+
const payloadAccess =
562+
subject === 'admin'
563+
? [
564+
{
565+
type: 'registry',
566+
class: '',
567+
name: 'catalog',
568+
actions: ['*'],
569+
},
570+
]
571+
: access;
561572
const payload = {
562573
jti: randomUUID(),
563574
nbf: Math.floor(Date.now() / 1000) - 10,
564-
access,
575+
access: payloadAccess,
565576
};
566577
const options = {
567578
algorithm: CERT.algo,
@@ -571,6 +582,8 @@ const generateToken = (
571582
expiresIn: REGISTRY_TOKEN_EXPIRY_SECONDS,
572583
keyid: CERT.kid,
573584
};
585+
console.error('=== payload:', JSON.stringify(payload, null, 2));
586+
console.error('=== options:', JSON.stringify(options, null, 2));
574587
return jsonwebtoken.sign(payload, CERT.key, options);
575588
};
576589

0 commit comments

Comments
 (0)