Skip to content
OASIS SAML 2.0, rule by rule

SAML 2.0 sign-in for Rust, at both ends

Accept a browser login, or issue one from your own identity provider. The same crate reads metadata and runs Single Logout.
Readme

Sign a person in with SAML 2.0, or issue that login from your own identity provider. Signatures and encryption go through bergshamra, so the build does not need libxml2, xmlsec1, or OpenSSL.

Cargo.toml
[dependencies]
saml-rs = "0.6"

The package name is saml-rs. Rust imports saml_rs. Method signatures live on docs.rs.

Start here
Service provider
sp.rs
let sp = Saml::sp(
SpConfig::builder(EntityId::try_new("https://sp.example.com/metadata")?)
.acs_endpoint(AcsEndpoint::post("https://sp.example.com/acs")?)
.credentials(credentials)
.validation(SpValidationPolicy::recommended())
.build()?,
)?;
let started = sp.start_sso(&idp, StartSso::redirect())?;

Store started.pending, send started.outbound to the browser, and call finish_sso when it posts back. The full flow is in Service provider.

Before production
Reference