Skip to content

Commit ac1b5b4

Browse files
committed
More descriptive signature validation error
1 parent 4e5b1e4 commit ac1b5b4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Pages/Home/JwtDecoder/JwtDecoder.cshtml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,20 @@
561561
562562
if (jwksUrl) {
563563
await loadJwks(jwksUrl);
564+
565+
const headerAndPayload = jwtParts[0] + '.' + jwtParts[1];
566+
const signature = jwtParts[2];
564567
565568
if (jwks.keys.length === 0) {
566-
showSignatureValidationResult('warning', 'No JWKs loaded. Cannot validate signature.');
569+
if (signature) {
570+
showSignatureValidationResult('warning', 'The JWT has a signature, but no JWKs could be loaded to verify whether the signature is valid.');
571+
}
572+
else {
573+
showSignatureValidationResult('warning', 'No JWKs loaded and no signature to validate.');
574+
}
567575
return;
568576
}
569-
570-
const headerAndPayload = jwtParts[0] + '.' + jwtParts[1];
571-
const signature = jwtParts[2];
577+
572578
const result = await validateSignature(header, headerAndPayload, signature, jwks.keys);
573579
574580
if (result.signatureValidated) {

0 commit comments

Comments
 (0)