Skip to content

Single Logout

End a session that a typed SSO flow already created. You have an SsoSession and a peer that advertises a SingleLogoutService.

start_slo, receive_slo, respond_slo, and finish_slo run on both roles. Each exchange covers one peer. Your application owns the session store and coordinates logout across peers.

Service provider

  1. Read session.logout_subject().
  2. Call start_slo and store logout.pending with the browser session.
  3. When the identity provider answers, call finish_slo.
let subject = session
.logout_subject()
.ok_or("session has no logout subject")?;
let logout = sp.start_slo(
&idp,
subject,
StartSlo::post().apply_single_logout_generation_rules(),
)?;
store_with_session(logout.pending.snapshot());
let pending = Pending::<LogoutRequest>::from_snapshot(load_snapshot())?;
let completed = sp.finish_slo(
&idp,
&pending,
BrowserInput::<LogoutResponse>::post(response_fields),
validation,
)?;
let status = completed.status();

redirect(), post(), and simple_sign() leave the logout generation rules off until you call apply_single_logout_generation_rules(). With those rules selected, a session participant signs the request and sends the browser to an https logout URL. StartSlo::allow_http_single_logout() relaxes the https recommendation only.

Identity provider

  1. Call receive_slo with the browser fields from the LogoutRequest.
  2. Determine the affected sessions from the principal identifier and any SessionIndex values. Attempt logout at the other participants before ending the matching local sessions. Skip the initiating SP.
  3. Call respond_slo with the outcome in RespondSlo::status.

Use top-level Success when the IdP ends the local session or an error when it cannot. Add subordinate PartialLogout when another participant could not be contacted or failed to confirm logout. Omitting RespondSlo::status emits Success. Single Logout rules

The response carries the exact RelayState that arrived with the request. It may use another front-channel binding than the request; the service provider’s finish_slo accepts any front-channel binding its metadata publishes.

let logout_request = idp.receive_slo(
&sp,
BrowserInput::<LogoutRequest>::post(request_fields),
validation,
)?;
let status = logout_status_for(&logout_request)?;
let logout_response = idp.respond_slo(&sp, &logout_request, RespondSlo::post().status(status))?;

logout_status_for is application code that processes the sessions and their participants and builds the status.

When the identity provider starts logout itself, Saml<Idp>::start_slo is the session authority. It always emits LogoutRequest@NotOnOrAfter. The deadline comes from the same issuance lifetime used for assertion time bounds. The five-minute default is library policy. Why that does not claim an ordering against every historical assertion is in Logout expiration.

LogoutPolicy::recommended() requires a signature on logout requests and responses. LogoutPolicy::compatibility() is the legacy unsigned hatch.

Over SOAP

StartSlo::soap() and RespondSlo::soap() run the same calls as one back-channel SOAP exchange. Your HTTP client sends the request, and saml-rs reads the reply. Both peers publish SloEndpoint::soap(...). saml-rs signs every SOAP logout message it writes, and none carries RelayState. A received SOAP message must be signed under every LogoutPolicy. When your server or client authenticated the peer with mutual TLS, pass that with BrowserInput::soap_with_channel(body, channel); an unsigned message is then accepted, and a present signature is still checked.

let logout = sp.start_slo(&idp, subject, StartSlo::soap())?;
let request = logout.outbound.soap_request()?;
let reply_body = post_soap(request.endpoint().as_str(), request.envelope())?;
let completed = sp.finish_slo(
&idp,
&logout.pending,
BrowserInput::<LogoutResponse>::soap(reply_body),
validation,
)?;

The receiving side reads the posted body and returns the response envelope as the HTTP 200 body:

let logout_request = idp.receive_slo(&sp, BrowserInput::<LogoutRequest>::soap(body), validation)?;
let status = logout_status_for(&logout_request)?;
let logout_response = idp.respond_slo(&sp, &logout_request, RespondSlo::soap().status(status))?;
let reply_body = logout_response.soap_response()?.envelope();

Next

Follow the release checkout and Rust setup, then run the logout example from the repository root.

Terminal window
cargo run -p saml-rs --example slo

The last line prints the LogoutResponse status. The rules for each role are in Logout.