Home » OAuth2.0 and OIDC !
Security

OAuth2.0 and OIDC !


In today’s interconnected world, web security has become paramount. With the exponential growth of online services and digital interactions, safeguarding sensitive information and protecting user privacy are critical. Nowadays, Effective web security measures are essential to prevent cyber threats, data breaches, and unauthorized access, ensuring the integrity and reliability of modern digital solutions.

In this article, we will explore key authentication and authorization mechanisms crucial for modern security systems, OAuth 2.0 and OpenID Connect (OIDC).


What is OAuth2.0 ?

OAuth2.0 is an authorization framework that enables applications to obtain limited access to user accounts on an application which is exposed as an HTTP service like our famous Facebook where we can login using gmail account as a authentication account. We can use the same gmail account to login on multiple applications as SSO [Single-Sign-On].


OAuth2.0 works by delegating user authentication to the service that hosts the user account and authorizing third-party applications to access the user account. The Authorisation flow mechanisms differ for each devices like for Mobile phones, web applications, desktop applications etc. The Authorization Code Grant is the most common and secure flow. Here’s how it works:

Authorization Code Grant Workflow:

  • The user navigates to the website and clicks on the “Log In” button.
  • The website redirects the user to an OIDC Auth provider (e.g., Google, Okta) for authentication.
  • User will get redirected to the login Prompt.
  • The user logs in using their credentials at the OIDC provider.
  • After successful authentication, the OIDC provider redirects the user back to the e-commerce website with an authorization code.
  • Checks if the authorization was successful and will request for a token if successfully validated.
  • Website exchanges the authorization code for an ID Token and Access Token.
  • The ID Token is decoded, and user information (e.g., user ID, email) is extracted and request the user data with Token
  • Validates the token and sends the response.

What is OIDC ?

OpenID Connect (OIDC) is an authentication protocol built on top of OAuth 2.0. While OAuth 2.0 is used for authorization, OIDC adds an identity layer, allowing clients to verify the identity of the end-user and obtain basic profile information.

Security Aspects of OIDC:

ID Tokens: OIDC introduces ID tokens, which are basically JSON Web Tokens (JWTs) containing claims about the authentication of the user. These tokens are signed and optionally encrypted to ensure their integrity and confidentiality.

Authentication Flow: OIDC ensures that the user is authenticated through the authorization server, providing a seamless and secure way for users to log in to client applications.

User Information: The ID token can include information such as the user’s name, email, and other profile data, minimizing the need to request this information separately and reducing exposure of user credentials.

Nonce Parameter: OIDC uses the nonce parameter to mitigate replay attacks. The client generates a nonce, which is included in the authentication request and returned in the ID token to ensure the token’s validity.

Claims and Scopes: OIDC uses claims to convey information about the user and scopes to define the level of access, similar to OAuth 2.0 but with additional emphasis on identity.



To summarize, OAuth 2.0 provides a secure way to authorize third-party applications to access user resources without sharing user credentials which focuses on authorization while, OIDC builds on OAuth 2.0 to provide authentication, enabling clients to verify user identity and obtain basic profile information securely. Both protocols play a vital role in securing web and mobile applications by managing how users authenticate and authorize third-party applications to access their data.

I hope this article was informative. See you with another one soon.
Adios Amigo ………..!

Add Comment

Click here to post a comment