Passport-SAML

SAML 2.0 authentication strategy for Passport, supporting ADFS, Okta, Shibboleth, and OneLogin.

Library
npm
v3.2.4
881stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity56
Maintenance36
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture75
Code Quality78
Innovation58
Learning Curve75

Passport-SAML is a SAML 2.0 authentication strategy for Passport, the Node.js authentication middleware. It lets an Express (or any Passport-compatible) application act as a SAML service provider, redirecting users to an identity provider for single sign-on and validating the resulting SAML assertions before handing control back to the application’s own verify callback.

The package has been tested against OneLogin, Okta, Shibboleth, SimpleSAMLphp, and Active Directory Federation Services, and ships a MultiSamlStrategy variant that resolves SAML configuration per-request so a single strategy instance can serve multiple identity providers or tenants from one codebase.

All core SAML protocol handling (XML parsing, signature and certificate validation, assertion decryption) is delegated to the sibling @node-saml/node-saml library; Passport-SAML itself is a thin, fully-typed adapter that maps that protocol logic onto Passport’s authenticate/success/fail/error strategy contract.

What You Get

  • A Strategy class that handles SP-initiated login, IdP callback validation, and single logout (SLO) for one configured identity provider
  • A MultiSamlStrategy class that resolves SAML configuration per-request via a getSamlOptions callback, enabling one process to serve many IdPs or tenants
  • Support for HTTP-Redirect and HTTP-POST SAML bindings, including automatic form generation for POST-bound authentication requests
  • generateServiceProviderMetadata() for producing SP metadata XML that IdPs use to establish trust
  • Full TypeScript type definitions for strategy options, verify callbacks, and SAML profile shapes, re-exported from the underlying @node-saml/node-saml package

Common Use Cases

  • Adding enterprise SSO login to an Express/Node app so employees authenticate through their corporate IdP (Okta, ADFS, OneLogin) instead of a local password
  • Building a B2B SaaS product where each customer organization brings its own SAML identity provider, using MultiSamlStrategy to route each request to the right IdP configuration
  • Integrating with Active Directory Federation Services for internal line-of-business applications
  • Implementing SAML single logout (SLO) so a session ends across both the service provider and identity provider when a user signs out

Under The Hood

Architecture The package exports Strategy and MultiSamlStrategy (src/strategy.ts, src/multiSamlStrategy.ts), both extending a shared AbstractStrategy base that itself extends passport-strategy’s Strategy. AbstractStrategy.authenticate() inspects the incoming request for a SAMLResponse/SAMLRequest in the query string or body and dispatches to the corresponding @node-saml/node-saml validation method (validateRedirectAsync, validatePostResponseAsync, validatePostRequestAsync), then routes the resulting profile through user-supplied signon/logout verify callbacks that mirror Passport’s conventional (err, user, info) contract. MultiSamlStrategy overrides authenticate/logout/generateServiceProviderMetadata to first resolve per-request configuration through a caller-supplied getSamlOptions(req, done) callback, construct a fresh SAML instance from the resolved options, and then delegate to the parent implementation via prototype-swapping (Object.setPrototypeOf) rather than duplicating logic. Because essentially all SAML protocol work (XML parsing, signature/certificate validation, assertion decryption) is delegated to the sibling node-saml package, this library itself is a comparatively thin adapter layer between that protocol engine and Passport’s strategy interface — replacing the underlying SAML validation would mean changing node-saml, not this package.

Tech Stack Written entirely in TypeScript (strict mode, ES2018/CommonJS output via tsc), the runtime dependency surface is deliberately narrow: @node-saml/node-saml for SAML protocol logic, passport and passport-strategy for the Passport plugin contract, and @types/express/@types/passport for request typing. There is no database or persistence layer — session/state caching for validateInResponseTo is delegated to node-saml’s pluggable cache providers. Tooling includes ESLint with typescript-eslint, Prettier (enforced via prettier-plugin-packagejson), Mocha/Chai/Sinon for tests with nyc coverage reporting to Codecov, and release-it plus a GitHub-Actions changelog generator for releases.

Code Quality Two substantial spec files (test/strategy.spec.ts, test/multiSamlStrategy.spec.ts, roughly 370-380 lines each) exercise both strategy classes against a test/static fixture set of real certificates, keys, and sample SAML XML requests/responses — including a deliberately-broken signature fixture used to assert failure handling. TypeScript strict mode is enabled project-wide, errors are surfaced through Passport’s this.error()/thrown Error objects rather than swallowed, and CI runs a build-and-test workflow plus CodeQL security scanning on every push and pull request. No test files were found for the docs/example script, but the library’s own source is well covered.

What Makes It Unique Passport-SAML’s main differentiator versus generic SAML client libraries is MultiSamlStrategy: rather than hard-coding one identity provider per strategy instance, it resolves the SAML configuration dynamically per incoming request, which is what makes a single-tenant-per-strategy pattern usable for multi-tenant B2B SaaS products serving many customer IdPs from one process. The project also deliberately keeps this package as a thin Passport adapter and pushes all protocol logic into a separately maintained node-saml module, so the two can evolve and be audited independently — a pragmatic separation-of-concerns choice more than a novel algorithm.

Used by 8 apps in this directory

JavaScript
100%
Other

Automatisch

Automation · No Code Platforms

13,964

Self-hosted, no-code workflow automation that keeps your data on your own servers—a privacy-first alternative to Zapier with 90+ integrations.

View details
49
Repo Health
78
Technical
63
Dependency
Built with
JavaScript100%
Updated 6 months ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,600

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
70
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
97%
Other

Infisical

Security · Devops

29,145

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
65
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
81%
MIT

LibreChat

Developer Tools · AI Assistants

42,871

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
65
Dependency
Built with
TypeScript81%
JavaScript18%
Updated today
TypeScript
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,861

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
90
Repo Health
77
Technical
62
Dependency
Built with
TypeScript64%
Vue31%
Updated 2 days ago
JavaScript
63%
AGPL 3.0

overleaf

Collaboration · Productivity

18,090

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
82
Repo Health
80
Technical
62
Dependency
Built with
JavaScript63%
TypeScript29%
Updated 1 months ago
TypeScript
80%
Other

twenty

CRM

56,361

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript80%
MDX17%
Updated yesterday
Vue
47%
AGPL 3.0

Wiki.js

Knowledge Management · Collaboration

28,848

A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.

View details
72
Repo Health
67
Technical
60
Dependency
Built with
Vue47%
JavaScript42%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search