mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(JWT Node): Add an option to allow a "kid" (key ID) header claim (#9797)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -260,6 +260,20 @@ export class Jwt implements INodeType {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Key ID',
|
||||
name: 'kid',
|
||||
type: 'string',
|
||||
placeholder: 'e.g. 123456',
|
||||
default: '',
|
||||
description:
|
||||
'The kid (key ID) claim is an optional header claim, used to specify the key for validating the signature',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/operation': ['sign'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Override Algorithm',
|
||||
name: 'algorithm',
|
||||
@@ -349,6 +363,7 @@ export class Jwt implements INodeType {
|
||||
ignoreExpiration?: boolean;
|
||||
ignoreNotBefore?: boolean;
|
||||
clockTolerance?: number;
|
||||
kid?: string;
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -375,9 +390,12 @@ export class Jwt implements INodeType {
|
||||
secretOrPrivateKey = formatPrivateKey(credentials.privateKey);
|
||||
}
|
||||
|
||||
const token = jwt.sign(payload, secretOrPrivateKey, {
|
||||
const signingOptions: jwt.SignOptions = {
|
||||
algorithm: options.algorithm ?? credentials.algorithm,
|
||||
});
|
||||
};
|
||||
if (options.kid) signingOptions.keyid = options.kid;
|
||||
|
||||
const token = jwt.sign(payload, secretOrPrivateKey, signingOptions);
|
||||
|
||||
returnData.push({
|
||||
json: { token },
|
||||
|
||||
Reference in New Issue
Block a user