Complete SAML 2.0
Full implementation of SSO and SLO flows with all major bindings support
Learn more about Bindings
High-level API for Single Sign-On (SSO) and Single Logout (SLO)
import { ServiceProvider, IdentityProvider } from 'samlesa'
import { readFileSync } from 'fs'
const sp = ServiceProvider({
metadata: readFileSync('./sp-metadata.xml'),
privateKey: readFileSync('./sp-key.pem'),
signingCert: readFileSync('./sp-cert.cer'),
})
const idp = IdentityProvider({
metadata: readFileSync('./idp-metadata.xml'),
})
// Create login request
const { context, entityEndpoint } = sp.createLoginRequest(idp, 'redirect')
// Redirect user to IdP
res.redirect(`${entityEndpoint}?SAMLRequest=${encodeURIComponent(context)}`)import { IdentityProvider, ServiceProvider } from 'samlesa'
import { readFileSync } from 'fs'
const idp = IdentityProvider({
metadata: readFileSync('./idp-metadata.xml'),
privateKey: readFileSync('./idp-key.pem'),
})
// Create login response
const { context } = await idp.createLoginResponse({
sp,
requestInfo: { extract },
binding: 'post',
user: { NameID: 'user@example.com' },
})
// Send response to SP
res.send(`
<form method="POST" action="${acsUrl}">
<input type="hidden" name="SAMLResponse" value="${context}"/>
</form>
`)| Algorithm | Security | Recommendation |
|---|---|---|
| RSA-SHA256 | High | ⭐ Recommended |
| ECDSA-SHA256 | High | ⭐ Recommended |
| EdDSA-Ed25519 | Very High | ⭐ Recommended |
| RSA-SHA384/512 | High | ✅ Supported |
| Low | 🚫 Deprecated |
| Algorithm | Mode | Recommendation |
|---|---|---|
| AES-256-GCM | GCM | ⭐ Recommended |
| AES-128-GCM | GCM | ✅ Supported |
| AES-256-CBC | CBC | ✅ Supported |
| CBC | 🚫 Deprecated |
View all supported algorithms →
npm install samlesasamlify supports integration with major Identity Providers:
| Provider | Type | Difficulty |
|---|---|---|
| OneLogin | Enterprise IdP | 🟢 Easy |
| Okta | Identity Platform | 🟢 Easy |
| Azure AD | Microsoft Entra ID | 🟡 Medium |
| AWS SSO | AWS IAM Identity Center | 🟡 Medium |
| Keycloak | Open Source IAM | 🟡 Medium |
| GitLab | DevOps Platform | 🟢 Easy |
| Volcengine | China Cloud IdP | 🟡 Medium |
View all integration examples →
Released under the MIT License