More and more organizations are facing a situation when some applications are located on the corporate network (Active Directory, mail servers, etc.), while others (SaaS solutions) are located in private or public clouds. These organizations feel an urgent need to make their authentication and authorization processes both safe and easy. This challenge can be solved with single sign-on technology that authenticates a user without providing credentials to each resource.
In this article, we explain how you can start testing SSO applications at the earliest stages of development based on the two most popular communication standards: Security Assertion Markup Language (SAML) 2.0 and OAuth 2.0.
This article will be useful for quality assurance specialists and developers who are testing single sign-on solutions.
So what is single sign-on? Single sign-on (SSO) technology is now very popular due to its ability to enhance security and simplify administration of users and their access rights to various applications. With SSO, a user can log in at one place – a local PC, a web portal, a native application – and get access to various network resources without having to enter a password for each.
There are various benefits of SSO:
- SSO improves security of corporate resources, as user passwords aren’t sent between applications.
- SSO simplifies user administration, as access to new resources is provided at the configuration stage.
- With SSO, users no longer need to remember passwords to countless applications.
- SSO reduces the risk of phishing and other attempts at compromising a user’s credentials.
Organizations often use hybrid environments, where some enterprise applications are located on-premises while others run in the cloud. At this point, ensuring seamless integration becomes a real issue. One possible solution is to use SSO technology, where an outside identity provider serves as an authentication server.
Many SaaS providers allow for authenticating local Active Directory users by integrating a customer’s on-premises domain with the cloud domain. Active Directory (AD) is a Microsoft directory service that authenticates and authorizes all users in a Windows domain network through a domain controller, also known as an authentication server. Microsoft is also an SSO provider, offering Azure Active Directory as a reliable and scalable cloud service for identity and access management.
In order to understand how single sign-on works, let’s look at the following diagram, which illustrates the process of local user authentication and authorization in a Microsoft Azure cloud application:
Analyzing the above diagram, you may notice that any SSO solution for Windows should meet the following requirements:
- A client’s device should be a member of Windows AD.
- The local and cloud AD instances should be synchronized.
- The target application should support Kerberos authentication.
Let’s talk about how to meet all these requirements and start SSO testing even before all application functionality is implemented.
It’s great when our SSO solution covers all the requirements for authentication and authorization through Windows AD. But what if some of these conditions for single sign-on authentication can’t be met? For example, what if the client device isn’t a member of AD and/or it doesn’t support the Kerberos protocol?
These two authentication and authorization protocols allow for significantly expanding single sign-on implementations.
In particular, using either of these two protocols allows an SSO solution to provide access to terminal servers (like Remote Desktop Session Host for Windows domain users) and authenticate them through third-party cloud services like Okta, Azure, AWS, and OneLogin.
To begin, let’s explain the key terminology of SAML 2.0 and OAuth 2.0. These two tools use different terminology, but they’re conceptually the same.
Application through which a user initiates the target application (browser or native application)
Identity Provider (IdP)
Authorization Server (AS)
Service that provides user data and ensures its authenticity
Service Provider (SP)
Resource Server (RS)
Target application or another resource that handles authenticated requests
When using SAML 2.0 or OAuth 2.0 as an SSO protocol in Microsoft AD, the service provider (SP) acts as a trusted intermediary between the identity provider (IdP) and Microsoft Active Directory. Here’s how it works:
- The client is authenticated by the IdP or AS.
- The IdP issues SAML assertion for SAML 2.0, while the AS issues an access token for OAuth 2.0 (simply referred to as a token).
- The client sends the assertion/token to the SP/RS.
- The SP/RS validates the assertion with the IdP/AS.
- The SP/RS decrypts and validates user information received from the assertion and AD.
- The SP/RS provides the client with access to resources.
This solution has the following advantages:
- Integration into existing infrastructure doesn’t require significant changes to that infrastructure.
- You can use multiple identity providers in the same infrastructure.
- You can use multiple AD forests with one identity provider.
- Changing or adding an identity provider is seamless for users.
- The openness of the protocols used simplifies a security audit.
It’s best to begin testing SSO solutions based on SAML 2.0 and OAuth 2.0 as early as possible in order to reduce possible defects and costs of fixing them. For instance, you can create state transition diagrams when you are still developing specifications. This allows you to test whether the functionality of your application based on SAML 2.0 or OAuth 2.0 accounts for all possible steps a user may take during the authentication process. This approach allows you to discover business logic flaws in your application and fix them with minimum effort and cost.
Now, we’ll talk about preparing the infrastructure for testing SAML and OAuth-based SSO solutions.
Security Assertion Markup Language (SAML) is an open standard for exchanging authentication and authorization data between an identity provider, service provider, and client.
Here’s a scheme for user authentication based on SAML 2.0:
Azure, Okta, OneLogin, or any other similar service can be used as an IdP.
These tools allow you to start functional testing of your SSO solution even before all of your product functionality is developed. They also help you save the time of developers and reduce overall costs of application development by eliminating the need to develop special tools for SSO testing.
Benefits of using these SSO testing tools:
- Free to use
- Well-structured documentation and huge communities
- Infrastructure is easy to adjust to your SSO solution
- You can combine these tools, as they’re independent of each other
Drawbacks of using these SSO testing tools:
- Security risks, as user verification is done on the testing tool resources
Here’s what we need to do to make our SP work with the chosen IdP:
- Develop an application that supports SAML authentication (more details on this process here).
- Configure the local simpleSAMLphp application for authentication in your SSO application by making changes to \metadata\saml20-idp-remote.php
SimpleSAMLphp and the Okta IdP allow us to emulate the whole process of authenticating the user and receiving SAML assertion (a data package with information on the user and their signature).
Let’s see how the configured test environment works step by step:
- Run simpleSAMLphp:
- Go to the Authentication tab, select Test configured authentication sources, find Default-sp, and select your IdP.
- Then you’ll be redirected to the Authentication tab of the chosen IdP.
After successful authentication in the IdP, the SAML-based SSO application runs. Now, you can use Fiddler to intercept the SAML assertion where all the necessary data is stored.
You can change the information stored in the SAML assertion and add required user attributes. All these changes can be made in the settings of your SAML-based application on the IdP side.
OAuth 2.0 is an open standard for authentication and authorization that provides access to resources without giving them a login and password. Authorization is performed through tokens that are issued and confirmed with the authorization server.
Here’s a high-level model of OAuth 2.0 authentication:
Although the main purpose of OAuth 2.0 is to provide access to resources, it can also be used to provide SSO services, just like SAML.
Various cloud services – such as Azure, Okta, OneLogin, and AWS – can act as the authorization server. Therefore, when developing and testing solutions based on SAML or OAuth authorization, you can use a single infrastructure. And using a single infrastructure will allow you to spend less time on test environment preparation and continued support.
In our case, we used Postman to receive the access token for OAuth 2.0 authentication.
Postman is a convenient tool that provides an API development environment for automated testing. It has lots of built-in tools and is free for small teams.
The process of developing an application that supports OAuth 2.0 authentication and authorization is described here.
To receive the OAuth 2.0 access token, your SSO application should send a POST request with the following information:
- The address for sending the request: https://login.microsoftonline.com/<Tenant ID>/oauth2/token
- The request:
- Tenant ID is your Azure AD ID
- client_id and resource are the unique application ID of the application in your Active Directory
- Client_secret is a one-time key received when configuring the application key
After sending a request with valid data, we get the following reply:
The access token includes all the information needed for user authentication.
It’s important to test SSO solutions at the earliest stages of development, when application functionality is still only partially implemented and many operations must be performed manually. This way, you’re more likely to find any defects early and, as a result, significantly reduce the cost of fixing them.
Apriorit has a team of qualified quality assurance specialists who will be glad to assist you in testing your software solutions. Feel free to contact us via online chat or by filling out the form below.