SAML Authentication — Enterprise SAML 2.0 SSO Integration
DodaTech
Updated 2026-06-28
1 min read
In this tutorial, you'll learn about Saml Authentication. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
SAML 2.0 enables enterprise single sign-on through XML-based authentication assertions between identity providers and service providers.
// SAML SP configuration
const SamlStrategy = require('passport-saml').Strategy;
passport.use(new SamlStrategy(
{
entryPoint: 'https://idp.example.com/sso',
issuer: 'https://sp.example.com',
callbackUrl: 'https://sp.example.com/auth/saml/callback',
cert: fs.readFileSync('./idp-cert.pem', 'utf-8'),
signatureAlgorithm: 'sha256',
digestAlgorithm: 'sha256',
identifierFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
},
(profile, done) => {
// Map SAML attributes to user
const user = {
id: profile.nameID,
email: profile['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'],
name: profile['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'],
groups: profile['http://schemas.xmlsoap.org/claims/Group'] || []
};
return done(null, user);
}
));
// Metadata endpoint for IdP configuration
app.get('/auth/saml/metadata', (req, res) => {
res.type('application/xml');
res.send(generateSPMetadata({
issuer: 'https://sp.example.com',
callbackUrl: 'https://sp.example.com/auth/saml/callback',
publicCert: fs.readFileSync('./sp-cert.pem', 'utf-8')
}));
});
SAML is the dominant enterprise SSO protocol with broad support across major identity platforms.
← Previous
Authorization Code with PKCE — Secure OAuth Flow for Mobile and SPA
Next →
OpenID Connect — OIDC Authentication Patterns for Modern Applications
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro