Outils pour utilisateurs

Outils du site


web:javascript:jwt

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
web:javascript:jwt [2022/04/10 21:56] – [jsonwebtoken] sgariepyweb:javascript:jwt [2022/04/10 22:11] (Version actuelle) – [Créer le endpoint JWKS] sgariepy
Ligne 89: Ligne 89:
 Import: Import:
  
-<code js>+<code javascript>
 import * as jwt from 'jsonwebtoken'; import * as jwt from 'jsonwebtoken';
 // ou // ou
Ligne 98: Ligne 98:
 Signer: Signer:
  
-<code js>+<code  javascript>
 const jwtToken = jwt.sign( const jwtToken = jwt.sign(
   { userId },   { userId },
Ligne 111: Ligne 111:
 Avec RS256: Avec RS256:
  
-<code js>+<code  javascript>
 const privateKey = fs.readFileSync('private.key'); const privateKey = fs.readFileSync('private.key');
 const token = jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' }); const token = jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' });
Ligne 118: Ligne 118:
 Vérifier: Vérifier:
  
-<code js>+<code  javascript>
 const authHeader = req.header('x-auth-token'); const authHeader = req.header('x-auth-token');
  
Ligne 132: Ligne 132:
 Verify asymetric : Verify asymetric :
  
-<code js>+<code  javascript>
 import jwks from 'jwks-rsa’; import jwks from 'jwks-rsa’;
  
Ligne 155: Ligne 155:
  
  
 +===== jwks-rsa =====
 +
 +
 +Importer:
 +
 +<code>
 +import jwks from 'jwks-rsa’;
 +// ou
 +import * as jwks from 'jwks-rsa';
 +<code>
 +
 +<code>
 +const jwksClient = jwksClient({
 +  cache: true,
 +  jwksUri: 'https://appleid.apple.com/auth/keys',
 +});
 +</code>
  
  
 ====== JOSE ====== ====== JOSE ======
 +
 +  * [[https://github.com/panva/jose/|GitHub]]
 +  * [[https://github.com/panva/jose/blob/main/docs/README.md|Documentation]]
  
 ===== Clé privée ===== ===== Clé privée =====
web/javascript/jwt.1649620597.txt.gz · Dernière modification : 2022/04/10 21:56 de sgariepy