DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • SAML vs OAuth vs OpenID Connect — Which One Suits You the Most?
  • 5 Ways Docker Can Improve Security in Mobile App Development
  • Emerging Mobile Threats and Defensive Strategies for Developers
  • Modern Digital Authentication Protocols

Trending

  • Prioritizing Cloud Security Risks: A Developer's Guide to Tackling Security Debt
  • AWS to Azure Migration: A Cloudy Journey of Challenges and Triumphs
  • Rust, WASM, and Edge: Next-Level Performance
  • The Role of AI in Identity and Access Management for Organizations
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. Open ID Connect Authentication With OAuth2.0 Authorization

Open ID Connect Authentication With OAuth2.0 Authorization

How Open ID Connect and OAuth2.0 allow for full-authentication.

By 
Hanil Kathuria user avatar
Hanil Kathuria
·
Jul. 26, 19 · Opinion
Likes (11)
Comment
Save
Tweet
Share
32.4K Views

Join the DZone community and get the full member experience.

Join For Free

In the previous decade, Open Authorization (OAuth) has emerged as an industry-standard protocol for authorization. Today, almost, every web application, mobile application uses OAuth 2.0 (latest version of OAuth) for authorization.

OAuth 2.0 is used by tech giants like Facebook, Google, and Twitter. It allows the users to give information about their accounts with third-party applications or websites. It is also used to provide mechanisms for user authentication. So, this has led many developers and API providers to incorrectly conclude that OAuth is itself an authentication protocol and, thus, they use it to perform authentication. The question here is: are they right in doing that?

Is OAuth 2.0 an Authentication Protocol?

The answer is no, but before we go into all of the specifics, let's take a look at some basic concepts. 

But before we begin. Let’s get a brief of some basic concepts.

Authentication: Authentication means verifying that someone is indeed who they claim to be and, whether they are logged in or not.

Authorization: Authorization means deciding which resources a user can access, and what they should be allowed to do with those resources.

Resource Owner: The owner of the resource.

Resource Server: Resource Servers host resources of different users.

Client: It is the application accessing the resource server.

Authorization Server: It is the server issuing access tokens to the client after successful authorization.

OAuth 2.0

The OAuth 2.0 specification defines a delegation protocol that provides clients with “secure delegated access” to server resources on behalf of a resource owner (user). Basically, it specifies a process for users to authorize third-party to access their server resources without sharing their credentials. It is meant to work with HTTP and allows the authorization server to assign access tokens to third-party clients with the approval of a special resource owner. The client’s back channel (application server) then uses the access token to access the protected resources that is hosted by the resource server. In most cases, the resource server and authorization server are the same. The flow of OAuth 2.0 is explained below:

Oauth2 authorization code flow

Oauth2 authorization code flow


OAuth 2.0 is used in a wide variety of applications, be it web or mobile applications. It is also used for providing mechanisms for user authentication. This has led many developers and API providers to incorrectly conclude that it is an authentication protocol. Here, they are making a big mistake.

Not an Authentication Protocol 

A full authentication protocol will provide you with information about the end-user, such as a unique identifier, an email address, and what to call the user when he/she opens the application. It is all about the user and their presence within the application, and an internet-scale authentication protocol needs to be able to do this across network and security boundaries.

However, OAuth 2.0 sends none of this to the application; it only asks for an access token, gets the token, and eventually uses that to access some API. It doesn’t even know anything about who authorized the application or if there was a user there at all.

Although it isn't technically an authentication protocol, it is possible to use it to build one. Tech giants like Google, Facebook, and Microsoft were doing it prior to 2014. However, they faced issues, as there were custom hacks on the top of OAuth 2.0 to get users' information. Because there is no standard way of getting user information in OAuth 2.0, all these implementations were different from one another, and, therefore, they were not inter-operable.

As a solution, developers added an extension on top of OAuth 2.0 to get the missing functionality required for authentication. Why do all of this on top of OAuth? Why not create a separate protocol for authentication? The answer is because OAuth 2.0 already solves the delegation authorization problem very well, and it is close to act as an Authentication protocol. So, why to create a new protocol when added functionality could make it an authentication protocol.

OpenID Connect for OAuth 2.0

OpenID Connect is an identity layer developed on top of the OAuth 2.0 protocol. It lets clients confirm the identity of and receive basic profile information about the end-user based on the authentication done by using an authorization server. App and web developers use it to authenticate users without taking the responsibility of storing and managing passwords. It even provides the functionality of Single Sign-On (SSO).

OpenID Connect makes standard authentication possible by adding several key components on the OAuth 2.0 (base layer):

ID Tokens

The OpenID Connect's ID Token is a signed JSON Web Token (JWT). This contains a set of information about the authentication session, including identifiers for the end-user, the identity of the provider who issued the token, and the client for which this token was created. The client parses the content of the ID Token and obtains the user’s information. The ID Token is issued in addition to an access token. This allows the access tokens to remain opaque to the client, as it is in OAuth. The Authorization Server signs the ID token with a private key that helps in preventing impersonation attacks. (I.e., the client verifies whether the ID token is modified or not.)

User authentication

OpenID Connect enables handling a user’s login or determining whether a user is logged in already.

User Info Endpoint

OpenID Connect defines a standard protected resource (e.g. user info, which contains information about the current user in case the information provided by ID token is not enough). The information provided by the user info endpoint is not part of the authentication process. This resource can be accessed by using access tokens.

OpenID Scope

OpenID Connect also defines a set of standardized scopes: OpenID, profile, email, address, and phone. The OpenID scope is a special scope that switches on the issuance of the ID token as well as access to the User Info Endpoint by the access token. The OpenID Connect scopes can be used with other OAuth scopes without any conflict.

The flow of OpenID Connect is explained below.

OpenID Authorization Flow

OpenID Authorization Flow


In the exchange of the authorization code, the client receives an ID token in addition to access token from the Authorization Server. This provides a standard way to get the user’s information, as compared to using OAuth 2.0.
Authentication protocol security mobile app OpenID End user

Published at DZone with permission of Hanil Kathuria. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • SAML vs OAuth vs OpenID Connect — Which One Suits You the Most?
  • 5 Ways Docker Can Improve Security in Mobile App Development
  • Emerging Mobile Threats and Defensive Strategies for Developers
  • Modern Digital Authentication Protocols

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!