HTTP-Redirect binding: DEFLATE and URL encoding
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
- Build the AuthnRequest XML.
- Compress it with DEFLATE, using raw DEFLATE (RFC 1951) without a zlib header.
- Encode the compressed bytes as Base64.
- Percent-encode the Base64 string, including
+,/and=. - Attach
SAMLRequest,RelayState,SigAlgandSignatureto 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.
| Format | Leading bytes | Browser API |
|---|---|---|
| raw DEFLATE | compressed data begins immediately | DecompressionStream('deflate-raw') |
| zlib | 78 01 / 78 9C / 78 DA | DecompressionStream('deflate') |
| gzip | 1F 8B | DecompressionStream('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
- The redirect binding is subject to URL length limits (2–8 KB depending on browser and proxy). Requests with many attributes usually switch to the POST binding.
- Copying from an address bar often brings
RelayStateandSignaturealong. Keep only the parameters you need. - A browser network panel may show the query value already decoded. Do not confuse the raw and decoded forms.
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 toolThis 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.