Skip to content

Introduce Jwt.Builder #6851

Closed
Closed
@jzheaux

Description

@jzheaux

Since there are many aspects to building a Jwt, it'd be nice to have a builder to simplify that work:

Jwt jwt = Jwt.withTokenValue("token")
        .header("alg", JwsAlgorithms.RS256)
        .claim(ISS, URI.create("https://idp.example.org"))
        .build();

The builder would contain at least four configuration methods:

header(name, value) // adds a header
headers(headers) // sets the header map
claim(name, value) // add a claim
claims(claims) // sets the claim map

And would be inlined in Jwt, as the code does with other builders like ClientRegistration.Builder.

To assist with type coherence, it could also have helper methods for the claims specified in RFC 7519.

Finally, it would be helpful to prove out the abstraction by updating NimbusJwtDecoder and NimbusReactiveJwtDecoder to use it.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions