Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
passport-auth0
Advanced tools
:information_source: Maintenance Advisory: With the release of https://github.com/auth0/express-openid-connect, we will no longer be adding new features to this library, however we will continue to maintain this library and fix issues. You can read more about the release of our new library at https://auth0.com/blog/auth0-s-express-openid-connect-sdk/
This is the Auth0 authentication strategy for Passport.js. Passport is authentication middleware for Node.js that can be unobtrusively dropped into any Express-based web application.
For Management API endpoints, please see the Node Auth0 SDK.
Full documentation with examples can be found in the Node.js Quickstart.
You can also see fully working demos using this library in our Auth0 blog:
The Auth0 Passport strategy is installed with npm.
npm install passport-auth0
The Auth0 Passport strategy enforces the use of the state
parameter in OAuth 2.0 authorization requests and requires session support in Express to be enabled.
If you require the state
parameter to be omitted (which is not recommended), you can suppress it when calling the Auth0 Passport strategy constructor:
const Auth0Strategy = require('passport-auth0');
const strategy = new Auth0Strategy({
// ...
state: false
},
function(accessToken, refreshToken, extraParams, profile, done) {
// ...
}
);
If you want to change the scope of the ID token provided, add a scope
property to the authenticate configuration passed when defining the route. These must be OIDC standard scopes. If you need data outside of the standard scopes, you can add custom claims to the token.
app.get(
'/login',
passport.authenticate('auth0', {scope: 'openid email profile'}),
function (req, res) {
res.redirect('/');
}
);
If you want to force a specific identity provider you can use:
app.get(
'/login/google',
passport.authenticate('auth0', {connection: 'google-oauth2'}),
function (req, res) {
res.redirect('/');
}
);
If you force an identity provider you can also request custom scope from that identity provider:
app.get(
'/login/google',
passport.authenticate('auth0', {
connection: 'google-oauth2',
connection_scope: 'https://www.googleapis.com/auth/analytics, https://www.googleapis.com/auth/contacts.readonly'
}),
function (req, res) {
res.redirect('/');
}
);
If you want to specify an audience for the returned access_token
you can:
app.get(
'/login',
passport.authenticate('auth0', {audience: 'urn:my-api'}),
function (req, res) {
res.redirect('/');
}
);
If you want to check authentication without showing a prompt:
app.get(
'/login',
passport.authenticate('auth0', {prompt: 'none'}),
function (req, res) {
res.redirect('/');
}
);
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 helps you to easily:
This project is licensed under the MIT license. See the LICENSE file for more info.
FAQs
Auth0 platform authentication strategy for Passport.js
The npm package passport-auth0 receives a total of 59,807 weekly downloads. As such, passport-auth0 popularity was classified as popular.
We found that passport-auth0 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 44 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.