opyeb samlview

samlview · Bindings

HTTP-Redirect binding: DEFLATE and URL encoding

Redirect binding, raw DEFLATE, percent-encoding, SigAlg and Signature, length limits

The AuthnRequest an SP sends to an IdP usually travels with the HTTP-Redirect binding. The address bar shows a long SAMLRequest=fZJN... string, and passing it straight to a Base64 decoder fails, because the redirect binding is not Base64 but a combination of compression and URL encoding.

The encoding order

  1. Build the AuthnRequest XML.
  2. Compress it with DEFLATE, using raw DEFLATE (RFC 1951) without a zlib header.
  3. Encode the compressed bytes as Base64.
  4. Percent-encode the Base64 string, including +, / and =.
  5. Attach SAMLRequest, RelayState, SigAlg and Signature to the query string.
AuthnRequest XML → raw DEFLATE → Base64 → percent-encode → query parameter

Decoding is the reverse: take the query value, percent-decode, Base64-decode and inflate the raw DEFLATE. Skip any step and you get invalid compressed data or garbled characters.

raw DEFLATE versus zlib

Many compression tools add a zlib wrapper (a two-byte header and an Adler-32 checksum). The redirect binding uses a raw stream without a wrapper. In the browser that is DecompressionStream('deflate-raw'); on a server it is zlib.inflateRawSync. Feeding a zlib-wrapped value to a raw inflater fails on the first byte, and the reverse is equally true.

FormatLeading bytesBrowser API
raw DEFLATEcompressed data begins immediatelyDecompressionStream('deflate-raw')
zlib78 01 / 78 9C / 78 DADecompressionStream('deflate')
gzip1F 8BDecompressionStream('gzip')

Signature parameters

In the redirect binding the signature travels as query parameters. SigAlg holds the algorithm URI and Signature the signature value. What is signed is the concatenation SAMLRequest=...&RelayState=...&SigAlg=... in that fixed order; re-encoding any value breaks it. This tool shows the parameters exist but does not verify the signature.

Length limits and practical tips

samlview accepts the whole query, finds SAMLRequest or SAMLResponse itself, and shows which steps (URL decode → Base64 → DEFLATE) it used.

Frequently asked questions

Can a SAMLResponse use the redirect binding too?

Yes. Logout responses and some configurations use a redirect-binding SAMLResponse, and the order is the same as for SAMLRequest.

Why compress at all?

XML repeats many tags and compresses well. Compression and encoding keep it inside URL length limits.

If it does not verify the signature, why show it?

Seeing which binding carries the signature and with which algorithm immediately reveals problems such as a missing signature or SHA-1. Verification itself belongs to the SP.

Paste the SAMLRequest from the address bar and follow the inflation steps.

Open the tool

This article follows OASIS SAML 2.0 Core (2005), SAML 2.0 Bindings, SAML 2.0 Profiles, XML Signature 1.1 and RFC 1951 (DEFLATE). Every example is synthetic data.