question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JwtParser needs a setVerifyingKey API

See original GitHub issue

The token signature validation requires the caller to specify a signing key. It does not make it obvious that this is a verify operation.

JwtParser setSigningKey(byte[] key);

JwtParser setSigningKey(String base64EncodedKeyBytes);

JwtParser setSigningKey(Key key);

In RsaSignatureValidator, the isValid method does a signature verification if the passed key is an instance of type PublicKey. If passed an instance of type PrivateKey, it signs the data again and compares signature.

But at JWTParser layer, the following APIs will provide a more clear description of the operation:

JwtParser setVerifyingKey(byte[] verifyingKey);

JwtParser setVerifyingKey(String base64EncodedVerifyKeyBytes);

JwtParser setVerifyingKey(PublicKey publicKey);

However setSigningKey keys has to be retained for backward compatibility.

setVerifyingKey can also help scenarios where a token issuer service is different from a token validator, and the private key need not to be shared among them.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lhazlewoodcommented, May 23, 2017

This is better self-documenting - I think it’s a good addition. Thanks for the issue!

0reactions
lhazlewoodcommented, Jul 23, 2018

Just noting that this isn’t as simple as expected: the SigningKeyResolver interface, its adapter, and anything else referencing such needs to be refactored. This is a change that’s probably better left for 1.0 (or at least a release after the more urgent 0.10.0 release).

Read more comments on GitHub >

github_iconTop Results From Across the Web

JwtParser (JSON Web Token support for the JVM 0.9.1 API)
Parses the specified compact serialized JWT string based on the builder's current configuration state and returns the resulting unsigned plaintext JWT instance.
Read more >
Controlling access to HTTP APIs with JWT authorizers
Unless you require ID tokens for API authorization, we recommend that you configure your routes to require authorization scopes. You can also configure...
Read more >
JSON Web Tokens - jwt.io
JSON Web Token (JWT) is a compact URL-safe means of representing claims to be transferred between two parties. The claims in a JWT...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found