
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
fastify-auth0-verify
Advanced tools
Auth0 verification plugin for Fastify, internally uses fastify-jwt and jsonwebtoken.
Just run:
npm install fastify-auth0-verify --save
Register as a plugin, providing one or more of the following options:
domain: The Auth0 tenant domain. It enables verification of RS256 encoded JWT tokens. It is also used to verify the token issuer (iss). Either provide a domain or the full URL, including the trailing slash (https://domain.com/).audience: The Auth0 audience (aud), usually the API name. If you provide the value true, the domain will be also used as audience. Accepts a string value, or an array of strings for multiple providers.issuer: The Auth0 issuer (iss), usually the API name. By default the domain will be also used as audience. Accepts a string value, or an array of strings for multiple issuers.secret: The Auth0 client secret. It enables verification of HS256 encoded JWT tokens.complete: If to return also the header and signature of the verified token.secretsTtl: How long (in milliseconds) to cache RS256 secrets before getting them again using well known JWKS URLS. Setting to 0 or less disables the cache.Once registered, your fastify instance and request will be decorated as describe by fastify-jwt.
In addition, the request will also get jwtDecode and authenticate decorators.
The first one is similar to jwtVerify but it just performs the JWT token decoding.
The second one can be used as preValidation hook to add authenticate to your routes. The token information will be available in request.user.
Example:
const server = require('fastify')()
server.register(require('fastify-auth0-verify'), {
domain: "<auth0 auth domain>",
audience: "<auth0 app audience>",
})
server.register(function(instance, _options, done) {
instance.get('/verify', {
handler: function(request, reply) {
reply.send(request.user)
},
preValidation: instance.authenticate
})
done()
})
server.listen(0, err => {
if (err) {
throw err
}
})
You can configure there to be more than one Auth0 API audiences:
const server = require('fastify')()
server.register(require('fastify-auth0-verify'), {
domain: '<auth0 auth domain>',
audience: ['<auth0 app audience>', '<auth0 admin audience>']
})
server.register(function(instance, _options, done) {
instance.get('/verify', {
handler: function(request, reply) {
reply.send(request.user)
},
preValidation: instance.authenticate
})
done()
})
server.listen(APP_PORT, err => {
if (err) {
throw err
}
})
See CONTRIBUTING.md
Copyright NearForm Ltd 2019. Licensed under the Apache-2.0 license.
FAQs
Auth0 verification plugin for Fastify
The npm package fastify-auth0-verify receives a total of 20,558 weekly downloads. As such, fastify-auth0-verify popularity was classified as popular.
We found that fastify-auth0-verify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.