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

NimbusJwtEncoder should simplify constructing with javax.security Keys #16267

Open
jzheaux opened this issue Dec 12, 2024 · 0 comments
Open

NimbusJwtEncoder should simplify constructing with javax.security Keys #16267

jzheaux opened this issue Dec 12, 2024 · 0 comments
Labels
status: ideal-for-contribution An issue that we actively are looking for someone to help us with type: enhancement A general enhancement

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Dec 12, 2024

Currently to construct a NimbusJwtEncoder with a single key takes something like the following:

OctetSequenceKey jwk = new OctetSequenceKeyGenerator(256)
    .keyID(UUID.randomUUID().toString())
    .algorithm(JWSAlgorithm.HS256)
    .issueTime(new Date())
    .generate();
JWKSource<SecurityContext> source = new ImmutableJWKSet<>(new JWKSet(jwk));
NimbusJwtEncoder encoder = new NimbusJwtEncoder(source);

whereas to do the converse in NimbusJwtDecoder is simpler:

NimbusJwtDecoder decoder = NimbusJwtDecoder.withSecretKey(key).build();

It would be nice if NimbusJwtEncoder offered similar behavior:

SecretKey key = ...
NimbusJwtEncoder.withSecretKey(key).build(); // or
NimbusJwtEncoder.withSecretKey(key).keyId(...).build(); // etc.

KeyPair keyPair = ... // RSA or EC
NimbusJwtEncoder.withKeyPair(keyPair).build(); // or
NimbusJwtEncoder.withKeyPair(keyPair).keyId(...).build(); // etc.
@jzheaux jzheaux added type: enhancement A general enhancement status: ideal-for-contribution An issue that we actively are looking for someone to help us with labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that we actively are looking for someone to help us with type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant