Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Verify: allow passing a function to `audience`

Open
#799 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript

Research direction

Start at the jwt.verify() entry point and trace how the audience option is consumed, including the pass-through from jwt-express described here. Use the dynamic audiences example to clarify the supported function return shape for a string or array, and add coverage showing that changed values are observed without restarting the app.

Written by the indexing model from the issue text.

Description

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.

Dominant language
JavaScript
Stars
18.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/node-jsonwebtoken

All issues in auth0/node-jsonwebtoken

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.