Merge 44af3fee38ec27e5194cc5d8dae3c048a451b5e2 into 037590f83128fb856f2e590f133201a39d2c7d2a
This commit is contained in:
commit
da6e6642eb
@ -19,6 +19,5 @@ export const JWT_ALGORITHMS = [
|
|||||||
"RS512",
|
"RS512",
|
||||||
"ES256",
|
"ES256",
|
||||||
"ES384",
|
"ES384",
|
||||||
"ES512",
|
"ES512"
|
||||||
"None"
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -26,6 +26,7 @@ class JWTSign extends Operation {
|
|||||||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||||
this.inputType = "JSON";
|
this.inputType = "JSON";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
|
const algorithmList = JWT_ALGORITHMS.concat(["None"]);
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
name: "Private/Secret Key",
|
name: "Private/Secret Key",
|
||||||
@ -35,7 +36,7 @@ class JWTSign extends Operation {
|
|||||||
{
|
{
|
||||||
name: "Signing algorithm",
|
name: "Signing algorithm",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: JWT_ALGORITHMS
|
value: algorithmList
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,12 +26,18 @@ class JWTVerify extends Operation {
|
|||||||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "JSON";
|
this.outputType = "JSON";
|
||||||
|
const algorithmList = JWT_ALGORITHMS.concat(["Any"]);
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
name: "Public/Secret Key",
|
name: "Public/Secret Key",
|
||||||
type: "text",
|
type: "text",
|
||||||
value: "secret"
|
value: "secret"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Signing algorithm",
|
||||||
|
type: "option",
|
||||||
|
value: algorithmList
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +47,8 @@ class JWTVerify extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [key] = args;
|
const [key, alg] = args;
|
||||||
const algos = JWT_ALGORITHMS;
|
const algos = (alg === "Any" ? JWT_ALGORITHMS : alg);
|
||||||
algos[algos.indexOf("None")] = "none";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const verified = jwt.verify(input, key, { algorithms: algos });
|
const verified = jwt.verify(input, key, { algorithms: algos });
|
||||||
|
|
||||||
|
|||||||
@ -50,38 +50,77 @@ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEVs/o5+uQbTjL3chynL4wXgUg2R9
|
|||||||
q9UU8I5mEovUf86QZ7kOBIjJwqnzD1omageEHWwHdBO6B+dFabmdT9POxg==
|
q9UU8I5mEovUf86QZ7kOBIjJwqnzD1omageEHWwHdBO6B+dFabmdT9POxg==
|
||||||
-----END PUBLIC KEY-----`;
|
-----END PUBLIC KEY-----`;
|
||||||
|
|
||||||
|
const signedInputs = {
|
||||||
|
HS: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.0ha6-j4FwvEIKPVZ-hf3S_R9Hy_UtXzq4dnedXcUrXk",
|
||||||
|
RS: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.MjEJhtZk2nXzigi24piMzANmrj3mILHJcDl0xOjl5a8EgdKVL1oaMEjTkMQp5RA8YrqeRBFaX-BGGCKOXn5zPY1DJwWsBUyN9C-wGR2Qye0eogH_3b4M9EW00TPCUPXm2rx8URFj7Wg9VlsmrGzLV2oKkPgkVxuFSxnpO3yjn1Y",
|
||||||
|
ES: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.WkECT51jSfpRkcpQ4x0h5Dwe7CFBI6u6Et2gWp91HC7mpN_qCFadRpsvJLtKubm6cJTLa68xtei0YrDD8fxIUA"
|
||||||
|
};
|
||||||
|
|
||||||
TestRegister.addTests([
|
TestRegister.addTests([
|
||||||
{
|
{
|
||||||
name: "JWT Verify: HS",
|
name: "JWT Verify: HS",
|
||||||
input: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.0ha6-j4FwvEIKPVZ-hf3S_R9Hy_UtXzq4dnedXcUrXk",
|
input: signedInputs.HS,
|
||||||
expectedOutput: outputObject,
|
expectedOutput: outputObject,
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "JWT Verify",
|
op: "JWT Verify",
|
||||||
args: [hsKey],
|
args: [hsKey, "HS256"],
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "JWT Verify: Invalid HS",
|
||||||
|
input: signedInputs.HS,
|
||||||
|
expectedOutput: "JsonWebTokenError: invalid algorithm",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "JWT Verify",
|
||||||
|
args: [hsKey, "RS256"],
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "JWT Verify: RS",
|
name: "JWT Verify: RS",
|
||||||
input: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.MjEJhtZk2nXzigi24piMzANmrj3mILHJcDl0xOjl5a8EgdKVL1oaMEjTkMQp5RA8YrqeRBFaX-BGGCKOXn5zPY1DJwWsBUyN9C-wGR2Qye0eogH_3b4M9EW00TPCUPXm2rx8URFj7Wg9VlsmrGzLV2oKkPgkVxuFSxnpO3yjn1Y",
|
input: signedInputs.RS,
|
||||||
expectedOutput: outputObject,
|
expectedOutput: outputObject,
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "JWT Verify",
|
op: "JWT Verify",
|
||||||
args: [rsPub],
|
args: [rsPub, "RS256"],
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "JWT Verify: Invalid RS",
|
||||||
|
input: signedInputs.RS,
|
||||||
|
expectedOutput: "JsonWebTokenError: invalid algorithm",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "JWT Verify",
|
||||||
|
args: [rsPub, "ES256"],
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "JWT Verify: ES",
|
name: "JWT Verify: ES",
|
||||||
input: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.WkECT51jSfpRkcpQ4x0h5Dwe7CFBI6u6Et2gWp91HC7mpN_qCFadRpsvJLtKubm6cJTLa68xtei0YrDD8fxIUA",
|
input: signedInputs.ES,
|
||||||
expectedOutput: outputObject,
|
expectedOutput: outputObject,
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "JWT Verify",
|
op: "JWT Verify",
|
||||||
args: [esPub],
|
args: [esPub, "ES256"],
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "JWT Verify: Invalid ES",
|
||||||
|
input: signedInputs.ES,
|
||||||
|
expectedOutput: "JsonWebTokenError: invalid algorithm",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "JWT Verify",
|
||||||
|
args: [esPub, "HS256"],
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user