Signature is generated differently on Node v4 and Node v6
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Iniziate da index.js, riga 35, dove hmac.digest('base64') segue hmac.update(thing), e riproducete l'output segnalato con il payload e il secret forniti su Node v4 e v6. Controllate la modifica all'encoding di Node crypto indicata dal link e verificate che il fix completato produca firme HS256 coerenti in entrambe le versioni, con copertura di regressione se il repository contiene test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello,
I'm trying to switch a project from Node v4 to Node v6, but I'm facing a little problem.
We are using node-jsonwebtoken, which use this library to sign jwt, and it seems that signatures are not generated the same way on node v4 and v6.
I've investigated the issue, I ended up here and found where it happens.
My secret and my payload look like this :
const crypto = require('crypto');
const secret = crypto.createHash('sha256').update('secret').digest('binary');
const payload = {
uid: 'test',
iat: 1455988418,
iss: 'test'
};
Then, if I generate a signature :
const jwa = require('jwa');
const algo = jwa('HS256');
const sig = algo.sign(payload, secret);
console.log(sig);
// Node v4 => "_zPq9vDP4_Ve0mTVTF_9H3NRkluQhoR4yAg8X4yqR8Q"
// Node v6 => "hk9bpxID-HOmvNpJUy7x80KqT5JP8tb_BoAJLYVIYsE"
After reading the code of this library, seems that the problem is coming from this line => https://github.com/brianloveswords/node-jwa/blob/master/index.js#L35
The signature is generated like this :
var sig = (hmac.update(thing), hmac.digest('base64'));
I went back to the crypto library, and found that crypto default encoding for digest has changed between node 4 and 6 ( https://github.com/nodejs/node/issues/6813#issuecomment-219753580 )
I tried to change in the lib hmac.update(thing) to hmac.update(thing, 'binary') but it changes nothing.
By the way, the secret generated is still the same between Node 4 and Node 6.
Do you have any idea of what is happening ?
Thanks a lot for this library, and for your help :)
Have a nice day.
- Lingua principale
- JavaScript
- Stelle
- 103
- Fork
- 44
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di auth0/node-jwa
-
Remove unnecessary safe-buffer dependency (use Node.js built-in Buffer API)Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Enhancement/ tech debt: use Node's built-in toString(base64url)Forse già presa @jimmywarting l’ha presa 1148 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
-
move from `buffer-equal-constant-time` to `timingSafeEqual`Forse già presa @jimmywarting l’ha presa 1148 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
-
Deprecating jwa and jws packagesForse già presa @jimmywarting l’ha presa 1148 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
Tutte le issue di auth0/node-jwa
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
guybedford/es-module-lexer#266 ·
-
bug documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
apify/apify-docs#3206 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
anhnt256/cursor-swarm#21 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
zerohourzulu/irontrellis#16 ·