GenAuth DocsDocuments
Concepts
User Guide
Development Integration
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Concepts
User Guide
Development Integration
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Old version
Concepts
  • What is GenAuth
  • What is User Pool
  • What is Application
  • What is Authentication
  • What is Federation Authentication
  • What is Zero Trust Network
  • Single Sign-On and Single Sign-Out
  • What is Authorization
  • Authentication vs Authorization
  • What is JWT Token
  • What is ID Token
  • What is Access Token
  • What is Refresh Token
  • Access Token vs Id Token
  • Understanding OIDC and OAuth2.0 Protocol

    • OIDC and OAuth2.0 Overview
    • Choose OIDC Authorization Mode
    • OIDC Common Questions
  • Understanding SAML2 Protocol

  • What is Multi-Factor Authentication
  • Account Lifecycle Management
  • Hosted Login Page vs Embeddable Login Component
  • CIAM and EIAM
  • What is LDAP
  • How QR Code Login Works
  • Basic Concepts of Cryptography
  1. Concepts
  2. /
  3. Understanding OIDC and OAuth2.0 Protocol

  4. /
  5. OIDC Common Questions

¶ OIDC FAQ

Update time: 2025-04-11 11:21:15
Edit

OIDC stands for OpenID Connect, a lightweight authentication + authorization protocol based on OAuth 2.0, and a superset of OAuth 2.0. It specifies how other applications, such as application A (XX mail system), application B (XX chat system), and application C (XX document system) you develop, retrieve user data from your central data table, and stipulates interaction methods, security specifications, etc., ensuring that your users only need to log in once when accessing all applications, instead of repeatedly entering passwords. In addition, following these specifications, your user authentication process will be very secure.

¶ How to handle OIDC in the backend

Please refer to the example on GitHub: example-spring-boot-oidc (opens new window)

¶ Comparison of the characteristics of the three authentication flows of OIDC

FeaturesAuthorization code modeImplicit modeHybrid mode
All tokens are returned from the authorization endpointnoyesno
All tokens are returned from the token endpointyesnono
Tokens are not exposed to the frontendyesnono
Clients can be authenticated by OPyesnoyes
Tokens can be refreshedyesnoyes
One interactionnoyesno
Server-to-server communication is requiredyesnovaries

¶ Authorization flows corresponding to different response-types

"response_type" valueFlow
codeAuthorization Code Flow
id_tokenImplicit Flow
id_token tokenImplicit Flow
code id_tokenHybrid Flow
code tokenHybrid Flow
code id_token tokenHybrid Flow

Refer to OIDC specification (opens new window)

¶ How to verify the legitimacy of the token

Please refer to:

Verify user identity credentials (token)

¶ User information corresponding to the scope parameter

scope nameCorresponding information
usernameusername
addressaddress
emailemail, email_verified
phonephone_number, phone_number_verified
profilebirthdate, family_name, gender, given_name, locale, middle_name, name, nickname, picture, preferred_username, profile, updated_at, website, zoneinfo
offline_accessIf this parameter exists, the token interface will return the refresh_token field
rolesThe user's role list corresponding to the role information
unionidThe user's unionid field
openidThe user's openid field
external_idThe user's user ID in the original system
extended_fieldsThe user's extended field information, the content is an object, the key is the extended field name, and the value is the extended field value

The above are the default supported by GenAuth Scope, you can also configure "Custom OIDC Scope" in the "Protocol Configuration" area of ​​the application.

¶ Meaning of OIDC user information fields

Field nameTranslation
subAbbreviation of subject, unique identifier, usually user ID
namegiven_name
family_namesurname
middle_namemiddle name
nicknamenickname
preferred_usernamepreferred name
profilebasic information
pictureavatar
websitewebsite link
emailemail
email_verifiedwhether the email is verified
gendergender
birthdatebirthday
zoneinfotime zone
localeregion
phone_numbermobile number
phone_number_verifiedverified mobile number
addressaddress
formatteddetailed address
street_addressstreet address
localitycity
regionProvince
postal_codePostal code
countryCountry
updated_atInformation update time

Refer to OIDC specification (opens new window)

¶ Difference between IdToken and AccessToken

IdToken is equivalent to the user's ID card. The developer's front-end should carry IdToken when accessing the back-end interface. Developer server should verify the user's IdToken. After verification, the relevant resources are returned. The OIDC application key or OIDC application public key can be used to verify the signature, and then the user ID and basic information corresponding to this token can be obtained. For example code, see: [Use application key to verify Token](/guides/faqs/how-to-validate-user-token.md#Use application key to verify-hs256-algorithm-signed-token).

AccessToken is used to request the resources held by the user on the GenAuth server. Your request to access the GenAuth server needs to carry this AccessToken in the Authorization request header. The sample code is as follows:

const axios = require("axios");
axios
  .get({
    url: "https://core.genauth.ai/api/your/resources",
    headers: {
      Authorization: "Bearer YOUR_OIDC_ACCESS_TOKEN",
    },
  })
  .then((res) => {
    // custom codes
  });

¶ Why does the OIDC authorization code process need to change the code to token and then to user information?

The authentication process of the OIDC authorization code mode involves three parties: the user, the OIDC server (OIDC Provider, referred to as OP), and the application business server (Service Provider, referred to as SP).

The purpose of interaction between SP, user, and OP is as follows:

  1. SP hopes to get a credible identity assertion so that the user can log in.

  2. SP initiates login and jumps to the OP's authentication page. OP asks the user to log in and authorizes his or her own information, and then OP sends an authorization code to SP. In fact, this is passing user information by reference.

  3. After receiving the authorization code, SP combines the Client ID and Client Secret to OP in exchange for the user's access_token.

  4. SP uses access_token to get relevant information about the user from OP, thereby obtaining a credible identity assertion and allowing the user to log in.

In the OIDC protocol, after the user successfully logs in, the OIDC authentication server will call back the user's browser to a callback address with an authorization code (code). This authorization code is generally valid for ten minutes and once, and becomes invalid after use. This avoids the risk of exposing the access_token or user information on the front end. The validity period of the access_token is relatively long, generally 1~2 hours. If it is leaked, it will have a certain impact on the user.

After the back end receives this code, it needs to use the Client Id + Client Secret + Code to exchange the user's access_token from the OIDC authentication server. In this step, the OIDC Server actually authenticates the OAuth Client to ensure that the machine that comes to the OIDC authentication server to obtain the access_token is trustworthy, not that anyone can come to the OIDC authentication server to exchange the code for a token after getting the code.

If the code is obtained by a hacker, he cannot use it if he does not have the Client Id + Client Secret. Even if he has it, he has to compete with the real application server, because the code is valid once and becomes invalid after use, which increases the difficulty of attack. On the contrary, if the access_token or user information is returned directly without the code, it will affect the user once it is leaked.

Previous article: Choose OIDC Authorization Mode Next article: SAML2 Overview
  • How to handle OIDC in the backend
  • Comparison of the characteristics of the three authentication flows of OIDC
  • Authorization flows corresponding to different response-types
  • How to verify the legitimacy of the token
  • User information corresponding to the scope parameter
  • Meaning of OIDC user information fields
  • Difference between IdToken and AccessToken
  • Why does the OIDC authorization code process need to change the code to token and then to user information?

User identity management

Integrated third-party login
Customized authentication process

Enterprise internal management

Single sign-on
Multi-factor authentication
Permission management

Developer

Development Documentation
GitHub (opens new window)

Company

official@genauth.ai
16th Floor, Building B, Beichen Century Center, Chaoyang District, Beijing (Total)
Room 406, 4th Floor, Block B, No. 200, Tianfu Fifth Street, High-tech Zone, Chengdu (Branch)

© Beijing Steamory Technology Co., Ltd.