Skip to content

Add JwtParserBuilder as the preferred way to create a JwtParser instance#486

Merged
bdemers merged 1 commit intomasterfrom
jwt-parser-builder
Oct 1, 2019
Merged

Add JwtParserBuilder as the preferred way to create a JwtParser instance#486
bdemers merged 1 commit intomasterfrom
jwt-parser-builder

Conversation

@bdemers
Copy link
Member

@bdemers bdemers commented Sep 16, 2019

run the build and look at for actual API changes: api/target/japicmp/japicmp.html

This PR still has a few warts and TODOs, but those could change based on feedback, thoughts/ideas welcome.

  • Added new JwtParserBuilder
  • Copied mutator methods from JwtParser into new JwtParserBuilder
  • Marked said methods as deprecated in JwtParser
  • Copied JwtParserTest and JwtsTest to Deprecated*, as to retain coverage on methods that will be removed in 1.0

Fixes: #473

Related README changes are in #499

Copy link
Contributor

@lhazlewood lhazlewood left a comment

Choose a reason for hiding this comment

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

Looking good! Just some comments and requests for changes.

<plugins>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this work exactly? I found https://siom79.github.io/japicmp/ but it's unclear to me what we're using this plugin for. Does it enforce semantic versioning?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, I've been using it in other projects for Semver (but we are still pre 1.0, so it will not block anything). I'll add a comment to describe it a bit more
Right now it's just configured to break on binary breaking changes (source breaking change are allowed, e.g. adding methods to interfaces)

* @return the parser method for chaining.
* @see MissingClaimException
* @see IncorrectClaimException
* @deprecated see {@link JwtParserBuilder#requireId(String)}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should make these deprecation notices super clear - why they're deprecated, and how they should be using the builder instead. A link to Jwts#parserBuilder() and some minor explanation should be ok.

Also, when I add a deprecation notice, I like to add it in the JavaDoc paragraph as well, with very clear (bold) indications that this method will be removed from 1.0 final.

* @return the builder for method chaining.
* @see MissingClaimException
* @see IncorrectClaimException
* @deprecated see {@link JwtParserBuilder#requireIssuer(String)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please see note re: deprecation

@lhazlewood
Copy link
Contributor

Oh also, we need to update the documentation to reflect this change everywhere. Also need to update the Changelog.

@coveralls
Copy link

coveralls commented Sep 17, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 499f715 on jwt-parser-builder into 7090bf3 on master.

@bdemers
Copy link
Member Author

bdemers commented Sep 17, 2019

@lhazlewood take another look, I just added an ImmutableJwtParser (impl) returned from Jwts.parserBuilder() which should protect anyone using the new method once drop the corresponding methods from JwtParser
Thoughts?

@bdemers
Copy link
Member Author

bdemers commented Sep 17, 2019

NOTE: I did NOT change the README, as to not confuse anyone before the 0.11.0 release

Copy link
Contributor

@lhazlewood lhazlewood left a comment

Choose a reason for hiding this comment

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

Just some minor change requests, other than that, looks good!

@bdemers bdemers added this to the 0.11.0 milestone Sep 18, 2019
@bdemers bdemers self-assigned this Sep 18, 2019
bdemers added a commit that referenced this pull request Sep 24, 2019
@bdemers bdemers force-pushed the jwt-parser-builder branch 3 times, most recently from 727b660 to 0e67ea7 Compare September 30, 2019 21:56
- Added new JwtParserBuilder
- Copied mutator methods from JwtParser into new JwtParserBuilder
- Marked said methods as deprecated in JwtParser
- Copied JwtParserTest and JwtsTest to Deprecated*, as to retain coverage on methods that will be removed in 1.0
- Added ImmutableJwtParser
  This is a stop gap until 1.0, all of the mutable methods will now throw a IllegalStateException.
  NOTE: this only comes into place when using the new Jwts.parserBuilder(), Jwts.parser() is unchanged.

Fixes: #473
@bdemers
Copy link
Member Author

bdemers commented Sep 30, 2019

@lhazlewood I hit some odd merge issues, but everything should be resolved now, take another look when you get a second.

Copy link
Contributor

@lhazlewood lhazlewood left a comment

Choose a reason for hiding this comment

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

Awesome! 🚀

@bdemers bdemers merged commit 94d1511 into master Oct 1, 2019
@bdemers bdemers deleted the jwt-parser-builder branch October 1, 2019 16:03
bdemers added a commit that referenced this pull request Oct 1, 2019
bdemers added a commit that referenced this pull request Oct 3, 2019
…nce (#486)

- Added new JwtParserBuilder
- Copied mutator methods from JwtParser into new JwtParserBuilder
- Marked said methods as deprecated in JwtParser
- Copied JwtParserTest and JwtsTest to Deprecated*, as to retain coverage on methods that will be removed in 1.0
- Added ImmutableJwtParser
  This is a stop gap until 1.0, all of the mutable methods will now throw a IllegalStateException.
  NOTE: this only comes into place when using the new Jwts.parserBuilder(), Jwts.parser() is unchanged.

Fixes: #473
lhazlewood pushed a commit that referenced this pull request Feb 4, 2020
- Docs: Adds section to README covering custom object parsing (#500)
- Docs: Add note about JwtParserBuilder creating an immutable JwtParser (#508)
Doc: #486
Fixes: #494
Doc: #495
Fixes: #171
lhazlewood pushed a commit that referenced this pull request Feb 5, 2020
- Docs: Adds section to README covering custom object parsing (#500)
- Docs: Add note about JwtParserBuilder creating an immutable JwtParser (#508)
Doc: #486
Fixes: #494
Doc: #495
Fixes: #171

Updated documentation and changelog to reflect the new Gson extension. Fixes #410. (#476)
lhazlewood added a commit that referenced this pull request Feb 5, 2020
…#559)

- Docs: Adds section to README covering custom object parsing (#500)
- Docs: Add note about JwtParserBuilder creating an immutable JwtParser (#508)
Doc: #486
Fixes: #494
Doc: #495
Fixes: #171

Updated documentation and changelog to reflect the new Gson extension. Fixes #410. (#476)

Co-authored-by: Brian Demers <brian.demers@gmail.com>
rtyley added a commit to guardian/play-googleauth that referenced this pull request Jul 4, 2024
* `signWith()` & `setSigningKey()` now prefer to be handed a `Key` type rather than a base64-encoded
String - deprecated in jwtk/jjwt#341
* To obtain a configured `JwtParser`, a builder is now preferred, ie
  `Jwts.parserBuilder().setSigningKey(key).build()` rather than `Jwts.parser().setSigningKey(key)` - deprecated
  in jwtk/jjwt#486
rtyley added a commit to guardian/play-googleauth that referenced this pull request Jul 4, 2024
* `signWith()` & `setSigningKey()` now prefer to be handed a `Key` type rather than a base64-encoded
String - deprecated in jwtk/jjwt#341
* To obtain a configured `JwtParser`, a builder is now preferred, ie
  `Jwts.parserBuilder().setSigningKey(key).build()` rather than `Jwts.parser().setSigningKey(key)` - deprecated
  in jwtk/jjwt#486

Note that `play-googleauth` currently supports two versions of Play:

* Play v2.9, uses jjwt v0.11.5
* Play v3.0, uses jjwt v0.12.6

...we need to support both, but thankfully everything we're using is supported in both versions of jjwt.
rtyley added a commit to guardian/play-googleauth that referenced this pull request Jul 4, 2024
* `signWith()` & `setSigningKey()` now prefer to be handed a `Key` type rather than a base64-encoded
String - deprecated in jwtk/jjwt#341
* To obtain a configured `JwtParser`, a builder is now preferred, ie
  `Jwts.parserBuilder().setSigningKey(key).build()` rather than `Jwts.parser().setSigningKey(key)` - deprecated
  in jwtk/jjwt#486

Note that `play-googleauth` currently supports two versions of Play:

* Play v2.9, uses jjwt v0.11.5
* Play v3.0, uses jjwt v0.12.6

...we need to support both, but thankfully everything we're using is supported in both versions of jjwt.
rtyley added a commit to guardian/play-googleauth that referenced this pull request Jul 4, 2024
* `signWith()` & `setSigningKey()` now prefer to be handed a `Key` type rather than a base64-encoded
String - deprecated in jwtk/jjwt#341
* To obtain a configured `JwtParser`, a builder is now preferred, ie
  `Jwts.parserBuilder().setSigningKey(key).build()` rather than `Jwts.parser().setSigningKey(key)` - deprecated
  in jwtk/jjwt#486
* Use `io.jsonwebtoken.security.SignatureException` rather than
  `io.jsonwebtoken.SignatureException` - deprecated in jwtk/jjwt#367

Note that `play-googleauth` currently supports two versions of Play:

* Play v2.9, uses jjwt v0.11.5
* Play v3.0, uses jjwt v0.12.6

...we need to support both, but thankfully everything we're using is supported in both versions of jjwt.
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.

Introduce JwtParserBuilder and migrate JwtParser.* mutator methods

3 participants