gamlastan
A comprehensive, pure-Rust SAML 2.0 library implementing the full specification with errata05 corrections.
Features
- Zero-copy parsing -- Borrowed
FooRef<'a>types reference the XML buffer directly; ownedFootypes for construction and storage - Full SAML 2.0 type system -- Assertions, protocol messages, metadata, status codes, name identifiers
- XML integration -- Built on uppsala for XML parsing and serialization
- Cryptographic operations -- XML-DSig signing/verification, XML Encryption, via bergshamra
- All protocol bindings -- HTTP Redirect, HTTP POST, HTTP Artifact, SOAP, PAOS, URI
- 32-check assertion validator -- Comprehensive security validation suite
- All SAML 2.0 profiles -- Web Browser SSO (SP + IdP), Single Logout, ECP, Artifact Resolution, Name ID Management/Mapping, IdP Discovery, Assertion Query
- Attribute profiles -- Basic, X.500/LDAP, UUID, DCE PAC
- SPID compliant -- Passes 263/263 Italian SPID conformance checks
- Errata05 -- Implements all 65 SAML 2.0 errata corrections
Modules
| Module | Description |
|---|---|
core |
SAML 2.0 types, constants, identifiers |
xml |
XML parsing (SamlDeserialize) and serialization (SamlSerialize) via uppsala |
crypto |
Signing, verification, encryption, decryption via bergshamra |
metadata |
EntityDescriptor, caching, validation, endpoint resolution |
bindings |
HTTP Redirect, POST, Artifact, SOAP, PAOS, URI, RelayState |
security |
Assertion validator, replay cache, clock skew, audience restriction |
profiles |
Web Browser SSO, SLO, ECP, Artifact Resolution, and more |
Zero-copy dual-type pattern
Every SAML data type has two variants:
// Borrowed -- all fields are &'a str, zero heap allocation during parsing
let response_ref: = parse_saml?;
// Owned -- all fields are String, for construction and long-lived storage
let response: Response = response_ref.to_owned;
Usage
Parse and validate a SAML Response:
use uppsala;
use parse_saml;
use ResponseRef;
let doc = parse?;
let response: = parse_saml?;
assert!;
Build and serialize an AuthnRequest:
use AuthnRequestOptions;
use create_authn_request;
use SamlSerialize;
let options = AuthnRequestOptions ;
let request = create_authn_request;
let xml = request.to_xml_string?;
Web framework integration
See gamlastan-actix for ready-to-use actix-web extractors, responders, and SP/IdP handlers.
License
BSD-2-Clause