-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance JWTParser #265
Enhance JWTParser #265
Conversation
Note I've also deprecated a require issuer property - no such |
Hi All I've been busy syncing the verification and decryption key resolvers together, it is not bad, and I expect going forward, there will be very minimum duplication, right now one deals with the private keys, the other one with the public ones, but most of the code will be shared in time. |
I'd really like to have some progress on this issue, now it will unlikely make it to Quarkus 1.6.0.Final.
|
@sberyozkin, I'm meaning to take a look at this. I have not been able to commit the time it deserves yet, hopefully in a day or so. |
@MikeEdgar thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sberyozkin - a few comments/observations:
(1) I think using the mp.*
config name would be ideal if the behavior will not be changing between this and 1.2. Just my opinion.
(2) The two concrete key location resolver classes are very similar except for the configuration retrieval calls that it seems like more code could be moved to the abstract parent. Maybe add some abstract methods like getKeyContent
and getKeyLocation
to eliminate the specific calls to those methods for the decryption and public keys and move the instance Key
field to the parent as well?
(3) The new DecryptionKeyLocationResolver
is not covered by any tests. Just to make you aware. I think if something could be done to eliminate common code in (2), it would be less of a concern.
Otherwise, looks good. I'll wait for your feedback to the comments before approving.
implementation/src/main/java/io/smallrye/jwt/auth/principal/DefaultJWTTokenParser.java
Show resolved
Hide resolved
implementation/src/main/java/io/smallrye/jwt/auth/principal/DecryptionKeyLocationResolver.java
Outdated
Show resolved
Hide resolved
@MikeEdgar Thanks for starting the review
I was concerned about reusing the
Yeah, I've tried to push as much as possible to the abstract class but I've found it difficult to abstract cleanly more code given that one calls typed public key extraction methods in
It is tested indirectly in Thanks |
@MikeEdgar Hi Mike, so I've done some work around the key location verifiers and I've pushed most of the code down to the abstract class. Also added a unit test for the decryption key location verifier, and a test to check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sberyozkin - changes look good.
Hi Mike, thank you for finding the time to do the review - as always it helped :-) |
Fixes #262
This PR is large but only because it ports some of the MP JWT 1.2 branch into it. Fundamentally it is all pretty simple, it is all about making it straight-forward to convert an encoded token string to
JsonWebToken
as we've had several discussions around a simple verification/decryption API.For example, in Quarkus, we are talking about a fast way to create JWT as a cookie, and then verify/decrypt it on the way back, without using Jose4j/etc directly.
So this PR:
JWTParser
to verify or decrypt the token with all types of keys. If it is injected then the internal injectedJWTAuthContextInfo
will be reused and only the provided key parameters will be used to reset the specific properties. OrDefaultJWTParser
can be safely used directly.mpjwt12
branch (with a few improvements), this gives us a complete end to end support, where we can sign, encrypt, sign/encrypt with the builder API and correctly process withJWTParser
. Roberto was suggesting to do it earlier on the master branch, I did not want the newmp.*
properties, so for now I've added smallrye specific property which will be deprecated once MP JWT 1.2 is out...This is the last PR I'd like to do before the next release