Async / custom signers and verifiers
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- backend-api-design, cryptography, security
Research direction
Start with the algorithm resolver and signer entry points in lib/sign-stream.js, then trace how the jwsSign opts are handled. The work is complete when callers can supply a custom resolver and asynchronous signer/verifier that return Promises, with the related breaking API changes addressed.
Written by the indexing model from the issue text.
Description
Custom (asynchronous) signer/verifier support
When using an external secret store / key management service such as AWS KMS or Azure Key Vault, it is not always possible to have the private key or secret in application memory. Instead, the KMS is used to perform the signing and responds with the signature. As this is an external service it happens asynchronously.
Currently, it is not possible to use these types of asynchronous signing services with the JWS library (at least, not without some circumvention).
Describe the ideal solution
I would like to be able to provide a custom algorithm resolver and to support an asynchronous signer.
The jwsSign opts could take an option that replaces the jwa library for returning a signer/verifier pair. The signer/verifier could then return a Promise that resolves with the signature.
Alternatives and current workarounds
At the moment, the best workaround I can find is to effectively sign the token twice. Once with a random private key that is available in memory and then again using the KMS. The signature from the KMS is then used in place of the one generated in memory.
const { generateKeyPairSync } = require('crypto');
const jws = require('jws');
const keyPair = generateKeyPairSync('rsa', { ... });
async function sign(alg, payload) {
const signature = jws.sign({
header: { alg },
payload,
secret: keyPair.privateKey,
});
const jwsWithoutSig = signature.split('.', 2).join('.');
const sig = await someAsyncSigner(alg, jwsWithoutSig);
return `${jwsWithoutSig}.${sig}`;
}
Additional context
There have been other requests around this type of feature and I think the above proposal is the most generic way to achieve the ability to support async signing.
This should address these related issues: #34, #93
I am happy to work on this solution, but it will involve breaking changes as the sign/verify functions will become async instead of sync.
- Dominant language
- JavaScript
- Stars
- 721
- Forks
- 141
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/node-jws
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Remove unnecessary safe-buffer dependency (use Node.js built-in Buffer API)May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
OWASP/CheatSheetSeries#3018 ·
Maintainers usually reply within 1 day
-
Radix number block generates NaN after switching a negative or decimal number to binary, octal or hexPossibly taken @matthewalberto claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mit-cml/appinventor-sources#4246 · 1 comment ·
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 83/100
GoogleChrome/modern-web-guidance-src#3675 · 2 comments ·
Maintainers usually reply within 1 day