Saml 2.0
Saml 2.0
Many major corporations like Oracle and IBM also have identity
management systems that they sell.
The idea is that these identity management systems include not only
support for SAML authentication,
but also other authentication mechanisms like OpenID Connect, Directory
Services or can even act as authentication
brokers.
The entity which will take that request and do the actual work.
is called the Identity Provider, and it's really a part of the identity
management system.
The user who's actually logging into the system in SAML is also called the
subject. In the SAML request,
and in the SAML response - you will see the user being referred to as the
subject.
The browser, which is used for redirecting the request to the small identity
provider, is called the
user agent.
This makes sense because the browser is really acting on behalf of the
user to automatically forward
requests as needed.
In fact, the user agent is critical because there is no direct path between
the service provider and
identity provider.
The communication has to go via the user agent.
You could even have the identity management system in the cloud like
Okta.
So point being, many variations of the same architecture are possible, but
the ideas pertaining to Single
Sign-On and delegate authentication are valid for all of these
architectures.
So - armed with this knowledge, let's go through the SAML authentication
flow to get some concrete
idea about what requests and responses are being sent.
In other words, let's see how SAML solves the problem of cross domain log i
I'm also assuming here that the trust relationship between the SAML
identity provider and the SAML
service provider is already complete.
In other words, the administrator has set up a web application from
identity management console and
attributes specific to the service provider are known to the identity
provider.
Also, the application is set up with the information about the SAML
identity provider.
One quick way to achieve this is to exchange the SAML metadata file,
which is also an XML
formatted file. In this case, instead of setting the attributes separately,
SAML metadata file can
be created for the identity provider and one for the service provider.
The SAML identity provider can then just upload the SAML Service
Providers metadata file.
The same can be done by the service provider.
So user accesses the Web application for the first time using the URL that
is provided.
So at this point, the application does not have any valid session with the
user.
The application does not know who the user is, so it forwards the request
to a well-defined SAML identity
provider
Single sign on
URL
This single sign on URL is defined in the identity provider's metadata file.
And so the application knows about it.
We talked about this approach during the delegated authentication model.
The actual request is an XML, which is optionally signed and the format is
defined by the SAML protocol.
There are a number of ways this request can be sent.
It can be sent using the HTTP redirect mechanism.
In this case, the application
replies to request number 1 with an HTTP 302
Status code and add the SAML request.
This makes the browser send the HTTP get request with the SAML request
as part of the URL.
It can also be sent using HTTP post mechanism. In this case, when the
user accesses the application -
the web application will return an HTML page.
Which contains.
Necessary JavaScript code to automatically submit a similar request using
the post mechanism to the
SAML identity provider.
This is also very common.
The SAML protocol defines a field called protocol binding, which defines
what forward mechanisms to
use, whether to use HTTP redirect or to use HTTP post.
Either way, a similar request is sent to the SAML identity provider from the
browser.
As far as the SAML service provider is concerned, it has asked the browser
to send this request to
the identity provider.
Think now from the identity providers perspective.
An HTTP request has been sent to the identity provider.
But it doesn't know who the user is
So the identity provider will show a login screen.
to get the credentials of the user.
The user will enter his assigned username and password and will click on
the submit.
at which point the user credentials are sent to the SAML identity provider.
The SAML identity provider will grab the user and password and will
interact with the directory services,
The response will contain all of the attributes of the user or in this case,
we also call it subject.
The response example has the SAML assertion XML tag, which in turn
contains all the attributes
of the user.
In addition to the user attributes, the SAML assertion will also contain the
groups associated with
the user, which will be used by the application for authorization.
This response is sent back to the application URL, which handles the SAML
assertion.
And so in the SAML terminology, it is also called Assertion consumer
service.
URL
That's the ACS URL
Once the application gets this response, it will have to verify the SAML
response and the assertion.
The assertion is also called a token.
It's called the SAML token.
This is important because this response could have been sent by a rogue
user or an application.
So to protect against this, many validations are done on the SAML
response.
Check that the SAML token has not expired, its signatures can be verified
to make sure that it is
signed by the identity management system.
The assertion can be decrypted if it was encrypted in the first place.
Let me make an important point over here.
If you look at how the authentication was done by the SAML identity
provider, that's Arrow 3
and Arrow 4, the user entered the credentials and then the identity
provider verified that with
the directory services using LDAP
But if you think about it, the user already has logged into the enterprise
network using a username
and password.
So if everything is within their enterprise - that is the user, the identity
provider and the browser,
then the Samuel Identity Provider should be able to recognize the user,
even if the user does not provide
the credentials.
That's exactly what happens if everything is set up correctly for single
sign-on in an enterprise.
In this scenario, when request 2 is sent to the identity provider, the SAML
identity provider will
recognize the user as the one logged into the enterprise network and will
simply send back the same
response to the application without asking for credentials.
This provides for an excellent user experience.
This entire authentication flow that we just talked about is called the SP
initiated SAML single sign
flow
Both the service provider, as well as the identity provider, are entities,
and in SAML, they have an
Entity ID associated with them.
In requests and responses of SAML, you will see this entity very often.
For example, who is the issuer of a request?
Who is the recipient of the response and so on.
And EntityID would be used to refer to these rules.
Also, frequently, the service provider is also called the relying party.
So application service provider and the Relying Party refer to the exact
same entity.
We then mentioned that the user should use the same identity for all the
applications.
That's really ideal because we want a single password to be managed for
a user.
We don't want multiple passwords.
With SAML - this is possible as long as all the applications are written so
that they all integrate
with the common SAML identity provider.
In other words, the SAML identity provider knows all the applications and
their users.
More generally, this is the job of the identity management system - Okta,
ADFS etc
The identity management system will provide a URL for accessing the
dashboard.
So now all the action starts when the user logs into the dashboard.
The user will enter the dashboard URL and then from the login screen,
enter the username and password