-
Notifications
You must be signed in to change notification settings - Fork 475
How to use with Auth0
Rlok edited this page Sep 23, 2022
·
1 revision
Who is Auth0?
Auth0 is an easy to implement, adaptable authentication and authorization platform
It can serve as an identity and/or service provider for SAML federation.
-
Firstly you have to create a developer account on Auth0 and create your application.
Navigate to the Applications page by the left menu.
-
Click "Create Application", choose the "Regular Web Applications" and type your App name.
-
Your application is now ready to use like this.
-
Switch to the "Addons" tab and turn on "SAML2".
-
A popup window will show up with all information we needed.
- Issuer -
issuer
of the config parameter - Identity Provider Certificate -
cert
of the config parameter, that is a.pem
file - Identity Provider Login URL -
entryPoint
of the config parameter
- Issuer -
const SamlStrategy = require('passport-saml').Strategy;
const fs = require('fs');
[...]
passport.use(
new SamlStrategy(
{
path: "/login/callback",
entryPoint: "place_your_Identity_Provider_Login_URL_here",
issuer: "place_your_Issuer_here",
cert: fs.readFileSync('./path_to_your_downloaded_Identity_Provider_Certificate_file.pem', "utf-8"), // cert must be provided
},
function (profile, done) {
// for signon
findByEmail(profile.email, function (err, user) {
if (err) {
return done(err);
}
return done(null, user);
});
},
function (profile, done) {
// for logout
findByNameID(profile.nameID, function (err, user) {
if (err) {
return done(err);
}
return done(null, user);
});
}
)
);