Encrypt or sign the tokens with external service

Issue #187 new
Jordi Burgos created an issue

I am using the library to create and read tokens.

The infrastructure that I am using has AWS KMS to store our keys stored, sign and encrypt data.

However, JsonWebEncryption requires to have the actual key, which it is not possible when using KMS. KMS stores the keys but can not be retrieved.

Would it be possible to add a parameter to JsonWebEncryption that includes a Java function to encrypt the token? The same mechanism for signing a token.

i.e. jwe.setEncryptFunction()

JsonWebEncryption jwe = new JsonWebEncryption();
jwe.setPayload(jws.getCompactSerialization());

jwe.setEncryptFunction((keyId, bytes) -> {
   return kms.encrypt(keyId, bytes);
});
...

Comments (3)

  1. Log in to comment