Published April 26, 2026 | Version v1
Preprint Open

Zero-Dependency SAML 2.0 Enterprise Authentication for Post-Quantum Security Platforms: XML-Based Federated Identity Without External Cryptographic Libraries

Authors/Creators

Description

Enterprise adoption of quantum-safe security platforms requires integration with existing identity providers via SAML 2.0, yet standard SAML libraries introduce heavy dependency chains (xml-crypto, xml2js, passport-saml) that conflict with the zero-dependency security model essential for cryptographic tooling. We present a zero-dependency SAML 2.0 implementation for QCrypton that provides AuthnRequest generation, SAML Response parsing with attribute extraction, and XML digital signature validation (RSA-SHA256 and RSA-SHA1) using only Node.js built-in crypto and regex-based XML parsing. The implementation generates SAML AuthnRequests with configurable SP entity ID, assertion consumer service URL, and IdP SSO destination; parses SAML Responses to extract NameID (email), SessionIndex, and standard SAML attributes (givenname, surname); and validates RSA-based XML signatures by extracting SignatureValue and SignedInfo elements. We evaluate the implementation against Okta, Azure AD, OneLogin, and ADFS IdP configurations, demonstrating successful authentication flows with zero external dependencies and under 2ms total processing time per SAML response.

Key Contributions

  1. Complete SAML 2.0 SP implementation with zero external dependencies (115 LOC)
  2. XML digital signature validation using only Node.js built-in crypto
  3. Regex-based XML parsing eliminating xml2js/xmldom dependency chains
  4. Support for both RSA-SHA256 and RSA-SHA1 signature algorithms
  5. Standard SAML attribute mapping for cross-IdP compatibility

Technical Highlights

  • Implementation Size: 115 lines of code — 3 functions (generateSamlRequest: 25 LOC, parseSamlResponse: 45 LOC, validateSamlSignature: 35 LOC)
  • Dependencies: Zero external — uses only Node.js built-in crypto module
  • Dependency Comparison: passport-saml (15+ transitive deps), samlify (12+ deps), saml2-js (14+ deps) vs. QCrypton SAML (0 deps)
  • AuthnRequest: Template-based XML with 128-bit random ID (crypto.randomBytes), configurable SP entity ID, ACS URL, IdP SSO destination; base64-encoded with URL-safe transmission
  • NameID Format: emailAddress (urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress)
  • Protocol Binding: HTTP-POST (urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST)
  • Response Parsing: Regex-based extraction handling both saml: and saml2: namespace prefixes
  • Attribute Mapping: Maps 3 URI formats per field — full WS-Federation URI, shorthand (firstName), and underscore (first_name)
  • Status Validation: Verifies StatusCode ends with :Success; throws on non-success or missing NameID
  • Signature Algorithms: RSA-SHA256 (modern IdPs) and RSA-SHA1 (legacy ADFS compatibility)
  • Certificate Handling: Accepts both PEM-wrapped and raw base64 certificates; auto-wraps raw certs with PEM headers
  • IdP Compatibility: Tested against Okta (SHA-256), Azure AD (SHA-256), OneLogin (SHA-256), ADFS (SHA-1)
  • Configuration: Falls back to environment variables (SAML_SP_ENTITY_ID, SAML_IDP_SSO_URL, QCRYPTON_BASE_URL) for zero-code container configuration
  • Performance: AuthnRequest generation < 0.5ms, Response parsing < 0.5ms, Signature validation < 1.5ms, Total < 2.0ms

Integration: GET /auth/saml/login (redirect to IdP), POST /auth/saml/callback (process response, create session)

Files

paper15_saml_authentication.pdf

Files (127.6 kB)

Name Size Download all
md5:72413b8c01829426387f57089ae7b556
127.6 kB Preview Download