This article was originally published on bmf-tech.com.
Summary based on OpenID Connect Core 1.0.
RFC Terms (RFC 2119)
Term
Meaning
MUST / REQUIRED / SHALL
Absolute requirement
MUST NOT / SHALL NOT
Absolute prohibition
SHOULD / RECOMMENDED
Recommended (should be followed unless there is a special reason)
SHOULD NOT / NOT RECOMMENDED
Not recommended (should be avoided unless there is a special reason)
MAY / OPTIONAL
Optional (may or may not be implemented)
Overview
OpenID Connect (OIDC) is an authentication protocol that adds a simple identity layer on top of the OAuth 2.0 protocol.
While OAuth 2.0 is a framework for "authorization," OIDC achieves "authentication."
Item
OAuth 2.0
OpenID Connect
Purpose
Authorization
Authentication
Obtained
Access Token
ID Token + Access Token
User Information
Not standardized
Standard claims defined
Terminology
OAuth 2.0
OpenID Connect
Description
Authorization Server
OpenID Provider (OP)
Authenticates users and issues ID Tokens
Client
Relying Party (RP)
Application requesting authentication from OP
ID Token
A core concept of OIDC. A JWT (JSON Web Token) containing claims about the authentication event.
Structure of ID Token
Header.Payload.Signature
JWT consists of three parts, each Base64URL encoded.
Required Claims (REQUIRED)
Claim
Description
iss
Issuer Identifier. URL identifying the OP (https scheme, MUST)
sub
Subject Identifier. Identifier for the end user (255 characters or less, ASCII)
aud
Audience. The intended recipient of this ID Token. Must include client_id (MUST)
exp
Expiration Time. Validity period (UNIX time)
iat
Issued At. Time of issuance (UNIX time)
Conditionally Required Claims
Claim
Condition
Description
auth_time
When max_age is specified (REQUIRED)
Time of authentication
nonce
If included in the request (REQUIRED)
Countermeasure against replay attacks
Optional Claims
Claim
Description
acr
Authentication Context Class Reference. Authentication context class
amr
Authentication Methods References. Array of authentication methods
azp
Authorized Party. Authorized party (if aud has multiple values)
at_hash
Access Token Hash. Hash value of the access token
Signature and Encryption
Requirement
Strength
ID Token must be signed
MUST
Signature algorithm must be other than none
MUST
If encrypted, encrypt after signing
MUST
Three Authentication Flows
Flow Selection Guide
Flow
response_type
Use Case
Authorization Code Flow
code
Server-side applications
Implicit Flow
id_token or id_token token
Browser-based apps like SPAs
Hybrid Flow
code id_token / code token / code id_token token
When both characteristics are needed
1. Authorization Code Flow
The most recommended flow. Tokens do not pass through the User Agent.
sequenceDiagram
participant U as End User
participant UA as User Agent<br/>(Browser)
participant RP as Relying Party<br/>(Client)
participant OP as OpenID Provider
RP->>UA: (1) Redirect to OP
UA->>OP: (2) Authentication Request<br/>(scope=openid, response_type=code)
OP->>U: (3) Authenticate & Consent
U-->>OP: (4) Grant
OP-->>UA: (5) Authorization Code
UA-->>RP: (5) Redirect with Code
RP->>OP: (6) Token Request<br/>(code, client_secret)
OP-->>RP: (7) ID Token + Access Token
RP->>OP: (8) UserInfo Request (OPTIONAL)
OP-->>RP: (9) UserInfo Response
Feature
Content
Token Acquisition
Obtained from Token Endpoint
Client Authentication
Possible
Refresh Token
Can be issued
Security
High (tokens are not exposed to the browser)
2. Implicit Flow
For browser-based JavaScript applications.
sequenceDiagram
participant U as End User
participant UA as User Agent<br/>(Browser)
participant RP as Relying Party<br/>(JavaScript)
participant OP as OpenID Provider
RP->>UA: (1) Redirect to OP
UA->>OP: (2) Authentication Request<br/>(response_type=id_token token)
OP->>U: (3) Authenticate & Consent
U-->>OP: (4) Grant
OP-->>UA: (5) ID Token + Access Token<br/>(in URL Fragment)
UA-->>RP: (6) Extract Tokens
Feature
Content
Token Acquisition
Directly from Authorization Endpoint (URL fragment)
nonce
REQUIRED (countermeasure against replay attacks)
Client Authentication
Not possible
Refresh Token
Not issued
Security
Lower than Authorization Code Flow
Note: In OAuth 2.1, not recommended for security reasons. Use Authorization Code Flow with PKCE.
3. Hybrid Flow
A flow combining characteristics of Authorization Code Flow and Implicit Flow.
sequenceDiagram
participant U as End User
participant UA as User Agent<br/>(Browser)
participant RP as Relying Party
participant OP as OpenID Provider
RP->>UA: (1) Redirect to OP
UA->>OP: (2) Authentication Request<br/>(response_type=code id_token)
OP->>U: (3) Authenticate & Consent
U-->>OP: (4) Grant
OP-->>UA: (5) Code + ID Token<br/>(in URL Fragment)
UA-->>RP: (6) Redirect with Code + ID Token
Note over RP: Immediate authentication confirmation with ID Token
RP->>OP: (7) Token Request (code)
OP-->>RP: (8) Access Token + ID Token
response_type
From Authorization Endpoint
From Token Endpoint
code id_token
Code, ID Token
Access Token, ID Token
code token
Code, Access Token
Access Token, ID Token
code id_token token
Code, ID Token, Access Token
Access Token, ID Token
Authentication Request Parameters
Required Parameters (REQUIRED)
Parameter
Description
scope
Must include openid (MUST)
response_type
code, id_token, id_token token, code id_token, etc.
client_id
Client identifier registered with OP
redirect_uri
Must exactly match registered URI (MUST)
Recommended Parameters (RECOMMENDED)
Parameter
Description
state
Random value for CSRF protection
Optional Parameters (OPTIONAL)
Parameter
Description
nonce
Countermeasure against replay attacks. REQUIRED in Implicit/Hybrid Flow
display
How the authentication UI is displayed (page, popup, touch, wap)
Top comments (0)