Below we will take a look on OAuth 2.0 and how it works
OAuth 2.0Â is an authorization framework that defines a token-based authorization process for how third-party applications can get consented access to usersâ data. OAuth 2.0 is a very powerful protocol for user authorization, but it does not define a clear and secure way to handle user authentication.
OAuth 2.0 Workflow
Before we will discuss about OAuth 2.0 Workflow we should understand the four specific roles that are involved into OAuth 2.0:
In most cases, both Resource Server and OAuth Server are in one server.
OAuth 2.0 enables the resource owner (user) to give the client (the third-party application) access to their data without having to share their credentials. Instead, the credentials are shared with the authorization server, which issues an access token to the client. The client can then use this access token to get the userâs data from the resource server.
Access and Refresh Tokens
Access tokens can be stored in different formats, the most common being the JSON Web Tokens (JSON Web Token) format. This format allows the token to contain encrypted data, which can be securely retrieved before the token expires.
Access tokens are often short-lived and therefore need to be re-generated upon expiration. Refresh tokens are used to obtain new access tokens and often have a longer lifespan than access tokens.
Real-World example
Letâs take Google and StackOverflow as an example. Google doesnt send all your data to StackOverflow upon you signed up using Google. First, it sends an access token. Both Google and Stackoverflow stores that access token for future usage. When Stackoverflow wants to get details about you, it sends a request to google server with that access token. Then google server check the validity of token and if it is valid, Google sends requested data to Stackoverflow
OAuth 2.0Â is an authorization framework that defines a token-based authorization process for how third-party applications can get consented access to usersâ data. OAuth 2.0 is a very powerful protocol for user authorization, but it does not define a clear and secure way to handle user authentication.
The OpenID protocol was introduced in 2005 as an open standard for single sign-on (SSO) and decentralized user authentication. It allowed users to log in to multiple websites using a single digital identity. An example of this type of flow is logging in to multiple websites using a Google account. OpenID defines how user authentication can be simplified, but it does not specify how user information should be securely exchanged between the client application and the identity provider.
The OpenID Foundation realized the need to integrate authentication into OAuth 2.0, and in 2014, they released the OpenID Connect protocol.
By combining the two, developers can leverage the authorization capabilities of OAuth 2.0 while obtaining verified user identity from OpenID Connect.
To achieve this synergy, OpenID Connect introduces new endpoints and token types to the OAuth 2.0 framework. It extends the standard OAuth 2.0 authorization flow by adding the ID token as an additional response. The ID token contains essential user information, allowing the client application to establish the userâs identity with confidence.
Once a user has authenticated with Identity Provider (IdP) or OpenID Provider (OP), subsequent requests to other applications that support OpenID Connect can leverage the existing session. This eliminates the need for the user to log in multiple times.
These protocols provide standardized mechanisms for handling authentication and authorization, reducing the complexity of implementation and promoting interoperability across various systems and platforms.