I am trying to understand SSO using SAML. I have come across the RelayState parameter and am very confused exactly why it comes first in SSO to send encoded URLs? What exactly does it mean?
Please read the following from the Google Developer documentation:
Google generates a SAML authentication request. The SAML request is encoded and embedded into the URL for the partner's SSO service. The RelayState parameter containing the encoded URL of the Google application that the user is trying to reach is also embedded in the SSO URL. This RelayState parameter is meant to be an opaque identifier that is passed back without any modification or inspection
RelayState is an identifier for the resource at the SP that the IDP will redirect the user to (after successful login). It is a way to make the process of SSO more transient to the user because they are redirected again to the same page they originally requested at the SP.
The original meaning of
RelayState
is that the SP can send some value to the IDP together with theAuthnRequest
and then get it back. The SP can put whatever value it wants in theRelayState
and the IDP should just echo it back in the response.There is also another, de facto standard use for
RelayState
when using Idp-initiated log on. In that case, there is no incoming request from the SP, so there can be no state to be relayed back. Instead, theRelayState
is used by the IDP to signal to the SP what URL the SP should redirect to after successful sign on. That is not part of the SAML2 standard.It looks like Google is using
RelayState
for the target URL even on SP-initiated sign on, which is perfectly fine. But the IDP should, as the documentation says, just relay it back.As per official SAML document,