Skip to content
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

JWT Builder shortcuts #258

Merged
merged 1 commit into from
Jun 15, 2020
Merged

JWT Builder shortcuts #258

merged 1 commit into from
Jun 15, 2020

Conversation

sberyozkin
Copy link
Contributor

@sberyozkin sberyozkin commented Jun 12, 2020

This PR continues with making the builder API as compact as possible, introduces the shortcuts to optimize some flows.

  1. In the flow where the claims are built from the empty builder, Jwt.claims() transition is now optional, every time I see Jwt.claims().claim("a", "b") I think this is suboptimal.
    So, instead of Jwt.claims().issuer("issuer").subject("sub").sign() one can just do Jwt.issuer("issuer").subject("sub").sign().

  2. Creates sign(), encrypt and innerSignAndEncrypt shortcuts to optimize the flows where the keys are configured and where the default RSA algorithms are used:

  • Jwt.claims("/token.json").sign() is equivalent to Jwt.sign("/token.json")
    (same for the maps and jsonobject)
  • Jwt.claims("/token.json").jwe().encrypt() is equivalent to Jwt.encrypt("/token.json")
    (same for the maps and jsonobject)
  • Jwt.claims("/token.json").innerSign().encrypt() is equivalent to Jwt.innerSignAndEncrypt("/token.json")
    (same for the maps and jsonobject)
  1. Also added Instant overloads for the iss and exp claims

@sberyozkin sberyozkin added this to the 2.1.3 milestone Jun 12, 2020
Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@sberyozkin
Copy link
Contributor Author

@MikeEdgar @radcortez thanks

@sberyozkin sberyozkin merged commit 4d50e83 into smallrye:master Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants