Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Verify: allow passing a function to `audience`

Aperta
#799 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript

Direzione di ricerca

Parti dal punto di ingresso jwt.verify() e segui come viene utilizzata l’opzione audience, incluso il passaggio attraverso jwt-express descritto qui. Usa l’esempio delle audience dinamiche per chiarire la forma di ritorno supportata dalla funzione per una stringa o un array, e aggiungi una copertura che dimostri che i valori modificati vengono rilevati senza riavviare l’app.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the problem you'd like to have solved

We have a use case where our audience list comes from AWS Parameter Store and could be changed on the fly without having to restart the whole app.

Describe the ideal solution

It would be ideal to be able to pass a function that return the audience(s). Something like this;

// This could be updated elsewhere. 
// Could be an array ['audience1', 'audience2'] or just a string.
let audiences = []; ;

jwt.verify(token, secretOrPublicKey, {
  audience: function() {
    return audiences; return the reference to the list.
  }
});

Alternatives and current work-arounds

We actually are not calling jwt.verify() directly but uses jwt-express to create a middleware for token verification. jwt-express passes through the audience option to jwt.verify() internally. Here's what we currently have:

app.use(jwtExpress({ audience: audiences }));

The middleware only gets the copy of the list at the time the app starts. We could wrap the jwtExpress middleware inside another middleware that always returns the current copy of the audiences list, but it would be an ugly solution.

Lingua principale
JavaScript
Stelle
18.2k
Fork
1.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di auth0/node-jsonwebtoken

Tutte le issue di auth0/node-jsonwebtoken

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.