Authorization Code Flow with Proof Key for Code Exchange
PKCE (Proof Key for Code Exchange) is a security enhancement to the OAuth 2.0 Authorization Code Flow. It is designed for public clients, such as native apps and single-page applications (SPAs), that cannot securely store a client secret.
Why Use PKCE?
Public clients face unique security challenges:
Native Apps:
Cannot securely store a client secret due to potential reverse engineering or decompilation.
May use custom URL schemes (
myapp://
) that could be intercepted by malicious apps.
Single-Page Apps (SPAs):
Cannot securely store a client secret since their source code is exposed in the browser.
PKCE mitigates these risks by introducing an additional layer of verification using a dynamically generated Code Verifier and Code Challenge.
How PKCE Works in Login 3.0
Process Flow:
User Initiates Login:
The user clicks "Login" within the application.
Generate Code Challenge and Verifier:
The application generates a random
code_verifier
and a correspondingcode_challenge
(e.g., usingSHA-256
).
Redirect to Login 3.0 Authorization Endpoint:
The application sends the user to the
/authorize
endpoint with thecode_challenge
.
User Authenticates:
The user logs in using configured authentication options (e.g., email/password, social login).
Consent prompts are displayed if required.
Receive Authorization Code:
Login 3.0 returns a single-use authorization code to the application, tied to the
code_challenge
.
Exchange Code for Tokens:
The application sends the authorization code and
code_verifier
to the/oauth/token
endpoint.
Verification by Login 3.0:
Login 3.0 verifies the
code_verifier
against thecode_challenge
stored during the initial request.
Receive Tokens:
Login 3.0 issues an ID Token, Access Token, and optionally a Refresh Token.
Access API:
The application uses the Access Token to call the API and access protected resources.
API Responds:
The API responds with the requested data.
Enabling PKCE in Login 3.0
Contact the UPBOND Team
To enable PKCE for your application:
Provide the application details, including:
Name and description of the application.
Redirect URIs.
Required scopes and permissions.
Request PKCE configuration for the Authorization Code Flow.
The UPBOND team will:
Configure the
/authorize
and/oauth/token
endpoints to support PKCE.Test the setup to ensure secure authentication.
Enhancing Security with PKCE
Refresh Token Rotation
For SPAs and native apps, enable Refresh Token Rotation to:
Issue a new Refresh Token with each token request.
Invalidate the previous token upon exchange, reducing risk from compromised tokens.
Browser Privacy Considerations
Modern browsers implement Intelligent Tracking Prevention (ITP) and block third-party cookies. PKCE, combined with Refresh Token Rotation, ensures secure and seamless user experiences without relying on third-party cookies.
Last updated
Was this helpful?