21 Apr, 2023

OIDC: The Open Authentication Protocol

Penetration Testing as a service (PTaaS)

Tests security measures and simulates attacks to identify weaknesses.

Overview to OIDC 

OpenID Connect (OIDC) is an authentication protocol built on top of OAuth 2.0 that enables users to authenticate themselves on a web or mobile application using a third-party authentication service. It provides a standardized way of accessing identity information across applications and services and supports Single Sign-On (SSO) which allows users to log in once and access multiple web applications without having to enter their credentials each time. OIDC was introduced in 2014 to address some of the shortcomings of OAuth 2.0, which was primarily designed for authorization purposes rather than authentication. It uses JSON Web Tokens (JWTs) to exchange identity information between the identity provider and the web application. OIDC supports several different types of flows and scopes, each of which is designed for a specific use case. 

History of OIDC 

The OpenID Connect (OIDC) protocol was developed in 2014 as a way to improve upon the original OpenID authentication protocol, which had been introduced in 2005 but failed to gain widespread adoption due to its complexity and lack of standardization. OIDC was designed to be simpler and more flexible than its predecessor, and to provide a standardized way of accessing identity information across applications and services. 

Before the introduction of OIDC, developers typically used OAuth 2.0 to provide authentication for their applications, even though OAuth 2.0 was primarily designed for authorization purposes rather than authentication. This led to a number of problems, such as the need for developers to implement their own authentication mechanisms, resulting in inconsistencies and security vulnerabilities. 

In response to these challenges, a group of industry leaders, including Google, Microsoft, and Yahoo, formed the OpenID Foundation in 2007 to promote the development and adoption of open standards for identity management. The foundation’s primary focus was on developing a new authentication protocol that would build upon OAuth 2.0 and address some of its shortcomings. 

The result of this effort was the introduction of OIDC in 2014. OIDC was designed to be a simple, flexible, and scalable protocol that could be used for a wide range of use cases, from social login to enterprise identity management. It was built on top of OAuth 2.0, which provided a foundation for secure communication between different parties. 

OIDC was designed to be backward-compatible with OAuth 2.0, which meant that developers could use their existing OAuth 2.0 infrastructure and add OIDC functionality on top of it. This made it easy for developers to adopt OIDC and begin using it in their applications. 

Key Features of OIDC 

OIDC has several key features that make it a popular choice for developers who need to implement authentication in their applications. In this section, we’ll explore some of the key features of OIDC in detail. 

User Authentication  

One of the primary goals of OIDC is to simplify the authentication process for end-users. OIDC enables users to authenticate themselves using a third-party identity provider (IDP), eliminating the need for users to remember multiple usernames and passwords for different applications. The IDP authenticates the user and sends back an identity token to the application, which can be used to verify the user’s identity. This makes the authentication process more secure and easier for end-users. 

JSON Web Tokens (JWTs)  

OIDC uses JSON Web Tokens (JWTs) to exchange identity information between the IDP and the application. JWTs are compact, URL-safe, and easy to parse, making them an ideal format for exchanging identity information. A JWT consists of three parts: a header, a payload, and a signature. The header contains information about the JWT, such as the algorithm used to sign it. The payload contains the identity information, such as the user’s name and email address. The signature is used to verify the authenticity of the JWT. 

Single Sign-On (SSO)  

OIDC supports Single Sign-On (SSO), which allows users to log in once and access multiple applications without having to enter their credentials each time. This is achieved through the use of JWTs, which are used to exchange identity information between the IDP and the application. Once the user has logged in to the IDP, they can access multiple applications without having to enter their credentials again. 

Authorization  

OIDC is built on top of OAuth 2.0, which provides a foundation for secure communication between different parties. OAuth 2.0 is primarily designed for authorization purposes, but OIDC builds on top of it to provide authentication as well. OIDC enables clients to obtain authorization from users to access their protected resources, such as their email address or calendar events. 

Backward Compatibility with OAuth 2.0 

OIDC is designed to be backward-compatible with OAuth 2.0, which means that developers can use their existing OAuth 2.0 infrastructure and add OIDC functionality on top of it. This makes it easy for developers to adopt OIDC and begin using it in their applications. 

Extensibility  

OIDC is designed to be flexible and extensible, which means that it can be customized to meet the needs of different use cases. OIDC supports several different types of flows, each of which is designed for a specific use case. This makes it easy for developers to implement OIDC in their applications and customize it to meet their specific needs. 

Standardization  

OIDC is an open standard that is maintained by the OpenID Foundation. This means that it is widely adopted and supported by a large number of identity providers and application developers. The standardization of OIDC makes it easier for developers to implement it in their applications and for identity providers to support it. 

In summary, OIDC is a flexible, extensible, and standardized authentication protocol that provides a simple and secure way for users to authenticate themselves on web and mobile applications. Its support for JWTs, SSO, and backward compatibility with OAuth 2.0 makes it a popular choice for developers who need to implement authentication in their applications. Its extensibility and standardization make it a flexible and widely adopted protocol that can be customized to meet the needs of different use cases. 

How does OIDC work? 

OpenID Connect (OIDC) is an authentication protocol that allows users to authenticate and authorize access to web applications using a third-party identity provider (IdP) that is trusted by both the user and the application. OIDC is built on top of OAuth 2.0, which is a standard protocol for authorization. In this section, we will discuss the detailed steps of how OIDC works. 

User initiates the authentication request: The authentication process begins when the user initiates an authentication request to access a protected resource on a web application. The request is sent to the OIDC client, which is the application that requires the user’s authentication. 

The OIDC client sends an authorization request to the IdP: The OIDC client then sends an authorization request to the IdP. This request includes the client’s identity, the requested scope of access, and a redirect URL where the user will be sent after the authentication process is complete. 

The IdP authenticates the user: The IdP then authenticates the user. This may involve the user entering their username and password or using a more advanced form of authentication such as multi-factor authentication (MFA). Once the user is authenticated, the IdP generates an access token and sends it back to the OIDC client. 

The OIDC client validates the access token: The OIDC client then validates the access token received from the IdP. This involves checking the token’s signature, expiration date, and other information to ensure that the token is valid and has not been tampered with. 

The OIDC client requests user information from the IdP: If the access token is valid, the OIDC client then sends a request to the IdP for user information. This request includes the access token as well as a request for specific user information such as their name, email address, and other attributes. 

The IdP sends user information to the OIDC client The IdP then sends the requested user information to the OIDC client. This information is usually in the form of a JSON Web Token (JWT), which contains the user’s identity information as well as any additional claims requested by the OIDC client. 

The OIDC client authenticates the user Finally, the OIDC client can authenticate the user based on the information received from the IdP. If the user is successfully authenticated, they are granted access to the protected resource on the web application. 

In summary, the OIDC protocol provides a secure and reliable way for users to authenticate and authorize access to web applications. By using a trusted identity provider, users can authenticate once and then access multiple applications without needing to re-enter their credentials each time. This makes the authentication process more streamlined and convenient for users while also increasing security by reducing the risk of password theft and other forms of identity fraud.

How OpenID Connect is different from OAuth 2.0  

OpenID Connect (OIDC) and OAuth 2.0 are both widely used protocols for identity and access management on the web. While they share many similarities, there are some important differences between the two protocols that are worth noting. In this section, we will discuss the main differences between OIDC and OAuth 2.0. 

Purpose The main difference between OIDC and OAuth 2.0 is their purpose. OAuth 2.0 is primarily a protocol for authorization, whereas OIDC is a protocol for authentication. OAuth 2.0 is used to grant third-party applications access to a user’s resources without giving them full access to the user’s account. OIDC, on the other hand, is used to authenticate a user and provide them with a secure way to access resources across multiple applications. 

Authentication While OAuth 2.0 can be used for authentication, it was not designed specifically for this purpose. OIDC, on the other hand, includes features specifically designed for authentication. OIDC allows for user authentication to be delegated to a trusted third-party identity provider, which can provide advanced authentication features like multi-factor authentication (MFA). 

User Information OIDC includes a standard way to request and receive user information, whereas OAuth 2.0 does not. With OIDC, when a user is authenticated, their identity information is returned in a standardized JSON Web Token (JWT) format. This allows applications to receive a standard set of user information, such as name, email address, and user ID, without having to implement custom APIs for each identity provider. 

Token Format Another key difference between the two protocols is the token format used for authentication and authorization. OAuth 2.0 uses bearer tokens, which are simple tokens that are sent as authorization headers in HTTP requests. These tokens are relatively easy to intercept and replay, making them less secure for authentication. OIDC, on the other hand, uses JWTs, which include a digital signature to verify their authenticity and prevent tampering. 

Security Features OIDC includes several security features that are not included in OAuth 2.0. For example, OIDC includes the ability to verify the identity of the client application by making the request using a client secret. OIDC also includes support for signed requests, which helps prevent replay attacks and ensures that requests can only be made by authorized parties. 

While both OAuth 2.0 and OIDC are used for identity and access management on the web, they serve different purposes and include different features. OIDC includes advanced authentication features and standardized user information, making it more suitable for authentication and single sign-on (SSO) scenarios. OAuth 2.0, on the other hand, is primarily a protocol for authorization and does not include standardized user information or advanced authentication features. 

How to use OIDC 

To use OpenID Connect (OIDC) for authentication, there are a few steps that need to be taken. These steps may vary depending on the specific implementation of OIDC, but in general, the following steps are involved: 

Choose an Identity Provider (IdP): The first step in using OIDC for authentication is to choose an Identity Provider (IdP) that supports OIDC. Popular IdPs that support OIDC include Google, Microsoft, and Okta. The IdP will provide an OIDC client ID and a client secret that will be used to authenticate with the IdP. 

Add OIDC support to your application: The next step is to add OIDC support to your application. This typically involves adding an OIDC client library to your application code. Popular OIDC client libraries include the OpenID Connect library for JavaScript (oidc-client-js) and the Spring Security OAuth library for Java. 

Configure your application to use the IdP: Once you have added OIDC support to your application, you need to configure your application to use the IdP. This involves setting the client ID and client secret provided by the IdP, as well as configuring any necessary endpoints and scopes. 

Initiate the authentication flow: To initiate the authentication flow, your application needs to redirect the user to the IdP’s authorization endpoint. This endpoint typically requires the user to authenticate with the IdP using their username and password or other forms of authentication such as multi-factor authentication (MFA). 

Receive the authentication response: Once the user has authenticated with the IdP, the IdP will redirect the user back to your application’s redirect URL. The redirect URL will include an authorization code that can be used to request an access token from the IdP’s token endpoint. 

Exchange the authorization code for an access token: Your application can use the authorization code received from the IdP to request an access token from the token endpoint. The access token can then be used to make authenticated requests to the IdP’s API. 

Verify the access token: Before allowing access to your application’s resources, your application needs to verify that the access token is valid and has not been tampered with. This typically involves validating the token’s signature, expiration date, and other information. 

Use the access token to access resources: Once the access token has been verified, your application can use it to make requests to the IdP’s API or to your application’s resources. The access token should be included in the authorization header of HTTP requests. 

Security issues and Remediation 

Like any other authentication protocol, OpenID Connect (OIDC) has its own set of security issues that need to be considered to ensure secure authentication. Below are some of the common security issues with OIDC and the remediation measures that can be taken: 

Man-in-the-middle (MitM) attacks: MitM attacks can occur when an attacker intercepts the communication between the client and the identity provider. This can result in the attacker being able to steal the user’s credentials or gain unauthorized access to the user’s data. 

Remediation: To prevent MitM attacks, it is recommended to use HTTPS to encrypt communication between the client and the identity provider. This ensures that the communication between the two parties cannot be intercepted or tampered with by an attacker. 

Token theft: If an attacker gains access to the user’s access token, they can use it to impersonate the user and access their resources. 

Remediation: To prevent token theft, access tokens should be short-lived and have an expiration time. Additionally, it is recommended to use refresh tokens that can be used to obtain a new access token after the old one has expired. Access tokens should also be encrypted and signed to prevent tampering. 

Cross-site request forgery (CSRF) attacks: CSRF attacks can occur when an attacker sends a request to the identity provider on behalf of the user. This can result in the attacker being able to obtain the user’s credentials or access their data. 

Remediation: To prevent CSRF attacks, it is recommended to use CSRF tokens that are generated by the identity provider and included in requests sent by the client. The identity provider can then validate the token to ensure that the request is legitimate and not sent by an attacker. 

Phishing attacks: Phishing attacks can occur when an attacker creates a fake identity provider login page and tricks the user into entering their credentials. This can result in the attacker being able to steal the user’s credentials and access their data. 

Remediation: To prevent phishing attacks, it is recommended to educate users on how to identify legitimate identity provider login pages. Additionally, multi-factor authentication (MFA) can be used to provide an extra layer of security and prevent unauthorized access even if the attacker has obtained the user’s credentials. 

Insecure storage of access tokens: If access tokens are stored insecurely, they can be easily accessed by an attacker and used to gain unauthorized access to the user’s data. 

Remediation: To prevent insecure storage of access tokens, access tokens should be stored in a secure location such as the client-side storage or server-side storage with appropriate encryption and access controls. 

To ensure secure authentication with OIDC, it is important to take measures to prevent MitM attacks, token theft, CSRF attacks, phishing attacks, and insecure storage of access tokens. By following the recommended remediation measures, the security of OIDC-based authentication can be significantly improved. 

Books and References 

Here are some books and references related to OpenID Connect (OIDC): 

“OAuth 2.0: Getting Started in Web-API Security” by Matthias Biehl: This book covers the basics of OAuth 2.0 and OIDC and provides practical guidance on how to implement them in web applications. 

“OAuth 2.0 Simplified” by Aaron Parecki: This is a free online book that provides a simple and easy-to-understand introduction to OAuth 2.0 and OIDC. 

“OpenID Connect in Action” by Prabath Siriwardena: This book provides a comprehensive guide to implementing OIDC in web applications, and covers topics such as authentication flows, token management, and security considerations. 

These resources can provide a good starting point for learning and implementing OpenID Connect. 

Other Services

Ready to secure?

Let's get in touch