Authentication
This article describes the OAuth 2.0 Authorization Code Flow with PKCE, detailing the steps, endpoints, request payloads, and responses for initiating and completing user authentication.
OAuth 2.0 Authorization Code Flow with PKCE
This document outlines the OAuth 2.0 Authorization Code Flow with PKCE, detailing the steps, endpoints, request payloads, and responses involved in initiating and completing user authentication without a client secret.
1. User Initiates OAuth Flow
Action: User Redirect to Authorization Server
Purpose: The user initiates the OAuth flow by redirecting to the authorization server to request authorization.
Redirection URL Format:
Parameters:
client_id
: The ID of the client application (e.g.,client123
).redirect_uri
: The URI where the authorization server will send the user after authorization.response_type
: The type of response desired (e.g.,code
).scope
: The scopes requested (e.g.,openid profile email
).code_challenge
: A transformed value of thecode_verifier
(see step 3).code_challenge_method
: Method used to derive thecode_challenge
(typicallyS256
).
2. Authorization Server Redirects to Authentication Server
Action: Redirect to Authentication Server
Purpose: After validating the initial request, the authorization server redirects the user to the authentication server to initiate authentication if the session cookie is present. If the session cookie is not present, all authentication steps must be completed before proceeding.
Redirection URL:
3. Initiate Authentication
Endpoint: POST /authentication/start
POST /authentication/start
Purpose: Starts the authentication process, retrieves available authentication methods, and returns a session cookie.
Request Payload:
Response:
Session Cookie: Upon successful initiation, the server sets a session cookie in the user's browser to track the authentication session. This cookie should be sent with subsequent requests to maintain the session context.
4. Check Authentication Status
Endpoint: GET /authentication/status
GET /authentication/status
Purpose: Checks the current status of the authentication session based on the session cookie.
Query Parameters:
session_id
: The ID of the authentication session (e.g.,auth_session_123456
).
Response:
5. Perform Authentication Step
Endpoint: POST /authentication/authenticate
POST /authentication/authenticate
Purpose: Processes the specified authentication step based on the selected method.
Request Payloads for Different Authentication Methods:
Password Authentication:
Endpoint:
POST /authentication/authenticate
Request Payload:
SMS Authentication:
Endpoint:
POST /authentication/authenticate
Request Payload:
Email Authentication:
Endpoint:
POST /authentication/authenticate
Request Payload:
SSO Authentication:
Endpoint:
POST /authentication/authenticate
Request Payload:
Passkey Authentication:
Endpoint:
POST /authentication/authenticate
Request Payload:
WhatsApp Authentication:
Endpoint:
POST /authentication/authenticate
Request Payload:
Response:
6. Verify OTP (for SMS, Email, or WhatsApp)
Endpoint: POST /authentication/verify-otp
POST /authentication/verify-otp
Purpose: Verifies the one-time password (OTP) received via SMS, email, or WhatsApp.
Request Payload:
Response:
7. Complete Authentication
Endpoint: POST /authentication/complete
POST /authentication/complete
Purpose: Confirms the completion of all required authentication steps.
Request Payload:
Response:
8. Redirect Back to Authorization Server
Endpoint: GET /authorize
GET /authorize
Purpose: Redirects the user back to the authorization server to obtain an authorization code.
Query Parameters:
client_id
: The ID of the client application (e.g.,client123
).redirect_uri
: The URI where the authorization server will send the authorization code.response_type
: The type of response desired (e.g.,code
).scope
: The scopes requested (e.g.,openid profile email
).state
: A unique state value to maintain state between the request and callback.code_challenge
: The previously used code challenge.code_challenge_method
: The method used to create the code challenge.
Last updated