Socket
Socket
Sign inDemoInstall

passport-saml

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-saml

SAML 2.0 authentication strategy for Passport


Version published
Weekly downloads
117K
decreased by-5.03%
Maintainers
2
Weekly downloads
 
Created

What is passport-saml?

The passport-saml npm package is a SAML 2.0 authentication provider for Passport, the popular Node.js authentication middleware. It allows you to integrate SAML-based Single Sign-On (SSO) into your Node.js applications, enabling users to authenticate using their existing credentials from a SAML identity provider (IdP).

What are passport-saml's main functionalities?

SAML Strategy Configuration

This feature allows you to configure the SAML strategy for Passport. You can specify the callback path, the entry point URL of the IdP, and the issuer string. The provided function processes the SAML profile and calls the `done` callback to complete the authentication.

const passport = require('passport');
const SamlStrategy = require('passport-saml').Strategy;

passport.use(new SamlStrategy(
  {
    path: '/login/callback',
    entryPoint: 'https://example-idp.com/sso',
    issuer: 'passport-saml'
  },
  function(profile, done) {
    return done(null, profile);
  }
));

Protecting Routes

This feature demonstrates how to protect routes using the SAML strategy. The `/login` route is protected, and if authentication fails, the user is redirected to the home page. On successful authentication, the user is redirected to the specified route.

app.get('/login',
  passport.authenticate('saml', { failureRedirect: '/', failureFlash: true }),
  function(req, res) {
    res.redirect('/');
  }
);

Handling SAML Callback

This feature shows how to handle the SAML callback route. After the IdP redirects the user back to the application, Passport processes the SAML response. If authentication is successful, the user is redirected to the specified route; otherwise, they are redirected to the home page.

app.post('/login/callback',
  passport.authenticate('saml', { failureRedirect: '/', failureFlash: true }),
  function(req, res) {
    res.redirect('/');
  }
);

Other packages similar to passport-saml

Keywords

FAQs

Package last updated on 11 Oct 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc