What Is SAML authentication?
SAML stands for Security Assertion Markup Language. If an organization wants to authenticate its users without creating IAM roles, and to pass assertions between the source and the target in a cloud environment, SAML can do it.
This is part of a series of articles about SaaS architecture

SAML is a method of secure communication between parties using extensible markup language (XML). The following two endpoints are typically used in SAML:
- Identity provider: The source that makes the request is known as the “identity provider” and the user’s identity might be either username/password or username/OTP.
- Service provider: The “service provider” is the target that receives the request for verification, such as Gmail, AWS, or Salesforce. It keeps track of user permission records and grants access to Software as a Service (SaaS) applications. It also controls how long a user may stay signed in to an application and how the session is kept alive.
SAML is built on the notion of single sign-on (SSO). Users can sign in with the same credentials on all of an organization’s portals they have access to. SAML can also be used for access control list (ACL) permissions, in which it determines whether or not a user is authorized to access a specific resource. SAML 2.0 is the version of the SAML standard that enables web-based, cross-domain SSO. It was ratified in 2005.
Benefits of SAML
- For users and systems built independently by an organization, SAML enables both authentication and authorization.
- Once SAML is implemented, users no longer need to remember numerous credentials. One set of credentials gives access to all of the organization’s resources or systems.
- SAML is a standard that does not depend on any one system, so it works across multiple products and vendors without interoperability concerns.
- It uses a single point of entry to validate a user’s identity, so it can provide secure authentication without keeping user data or requiring directory synchronization. As a result, it removes the possibility of identity theft.
- With SSO, users sign in faster and with less hassle.
- Service providers also have lower administrative costs, because they don’t need to build separate authentication endpoints.
- It makes the system more dependable through “risk transference”, because it transfers responsibility based on identity.
The benefits of SAML for each stakeholder:
SAML vs OAuth
OAuth stands for “Open Authorization.” Like SAML, OAuth uses an authorization server to complete the login process, and both are based on the SSO principle. They differ in several ways:
- SAML is concerned with the user, whereas OAuth is concerned with the application.
- Users are managed centrally in SAML. When a user logs into his organization’s network, he has access to all the resources because everything is centralized. However, if a user wants to provide third-party websites access to his information from a website like Facebook or Google, OAuth is required.
- SAML can do both authentication and authorization, whereas OAuth can only do the latter.
- OAuth is based on JavaScript Object Notation (JSON), binary, or even SAML forms, whereas SAML is based on XML format.
- In SAML, a token is referred to as a SAML assertion. In OAuth, a token is referred to as an access token.
- If users need temporary access to resources, use OAuth instead of SAML because it is more lightweight.
How SAML authentication works

- The identity provider obtains the user’s credentials (username and password). SAML validates the user’s identity at this stage.
- The identity provider then verifies the credentials and permissions associated with that account. If the user’s credentials are correct, the identity provider responds with a token and the user’s approved response to access the SaaS application.
- This token is sent to the service provider using a POST request.
- The service provider then validates the token. If the token is valid, the service provider generates temporary credentials and directs the user to the desired application terminal.
Note: These steps work only if there is a “trust connection” between the identity provider and the service provider. The authentication process will fail if that does not exist.
How we can create a trust relationship between identity provider and service provider
The identity provider and the service provider must agree on the basic SAML configuration. If the configuration is not identical at both endpoints, SAML will not work.
How it works:
- First generate a certificate from the host machine. Then create a SAML document in XML format and submit it to the service provider.
- Similarly, generate a document on the service provider and then import it on the identity provider. That document includes certificate information, email address of the organization, and public key of the service provider.
SAML use cases
An organization can deploy its SAML infrastructure on-premises, in the cloud, or in a hybrid structure where part is in the cloud and part is on-premises. Two use cases follow.
Hybrid
Here, identity verification takes place on-premises and authorization takes place in the cloud. The user reaches the cloud resource directly, before authentication:
- Users can access cloud resources directly.
- For authentication, users will be redirected to an on-premises setup.
- The identity provider verifies the user’s identity and provides the SAML assertion for the service provider’s use.
- The service provider will validate the assertion, and the user will be sent to the web application.
Cloud-Based
Both the identity provider and the service provider are cloud-based in this scenario, and the apps are either cloud-based or on-premises.
- First, users will be redirected to the cloud infrastructure to verify their identity. Identity as a service (IaaS) is a term used to describe how identity providers work (IDAAS).
- Authentication will be handled via the identity provider. The identity provider assigns assertions after authentication.
- The service provider verifies the assertion and gives the user access to the web application.
How to Implement SAML on the Cloud
Deploying SAML in the cloud is relatively simple, because most cloud service providers now offer an option to do it automatically. Here is how to implement SAML on Google Cloud.
Step 1
Create an account on Google Cloud and enable the identity provider.
Step 2
Next, set up the provider.
- Go to Identity Provider -> Click on Add Provider -> Select SAML list from there -> Enter details such as Provider Name, Provider’s Entity ID, Provider’s SSO URL, Certificate (used for token signing).
- Go to Service Provider -> Provide Entity Id (that verifies your application).
Step 3
- Add application URL in the authorized domain.
Step 4
2. After adding all this information at different places, click on save.
Those are the basic steps. To secure the setup further, we can also use these measures:
- Signing request: Signing authentication requests makes them more secure.
- Link user accounts: The user may already have signed in to the program with a method other than username/password. In that case, we can link the existing account to the SAML provider.
- Re-authenticating user: When a user changes his email, password, or any other sensitive information, SAML must re-authenticate the user.
SAML authentication best practices
Beyond the basics above, these practices make SAML communication safer.
- For secure web communication, always use SSL/TLS, so all communication between users, identity providers, and service providers is encrypted at all times. An attacker attempting a man-in-the-middle attack is then unable to access or modify the data, which preserves the requests’ confidentiality and integrity.
- When creating a trust relationship between identity providers and service providers, configure identity providers to use HTTP POST, and for redirection of SAML responses, use the whitelisted domains. The service provider does not perform the authentication operation. If the domain is not whitelisted, attackers can manipulate the domain and redirect users to a malicious domain.
- Validate SAML XML documents against a schema so that unsanitized user input cannot pass. Always prefer a local copy of the schema, and do not download it from untrusted websites.
- Maintain a blacklist of the domains that the organization wants to exclude from the SAML authentication process.
- As an identity provider, we can manage the user through access control.
Simplifying SAML with Frontegg
SAML gives enterprise SaaS applications stronger security, simpler sign-in, and centralized access management. Integrating and maintaining it, however, can be a significant burden on development teams. Frontegg’s Customer Identity and Access Management (CIAM) platform simplifies implementing authentication protocols such as SAML.
With Frontegg, organizations can distribute identity management across teams, which reduces developer toil and lets stakeholders such as Product, Customer Success, and InfoSec manage authentication, authorization, and user management. This speeds up deployment and ensures that your application remains secure and up to date with the latest identity standards, so developers can focus on high-priority projects.
Frontegg turns identity management into a shared job across your organization.
Put this into practice with Frontegg
Frontegg is customer identity and access management (CIAM) for B2B SaaS. It's free up to 7,500 monthly active users, including 5 SSO/SCIM connections.
Start for freeThe Complete Guide to SaaS Multi-Tenant Architecture
Read the guide