An enterprise mobile application authenticates users via a cloud-hosted Identity Provider (IdP) using the OAuth 2.0 Authorization Code Flow with Proof Key for Code Exchange (PKCE). Place the operational steps of this authentication sequence in the correct order, from initial client initialization to final token delivery.
- 1The client application generates a secret code_verifier and calculates its SHA-256 hash to create the code_challenge.
- 2The client redirects the user to the IdP authorization endpoint, transmitting the client_id, requested scope, and code_challenge.
- 3The IdP authenticates the user, records the code_challenge, and issues a temporary authorization code back to the client.
- 4The client application sends a DIRECT POST request to the IdP token endpoint containing the authorization code and plaintext code_verifier.
- 5The IdP hashes the code_verifier, confirms it matches the stored code_challenge, and issues the access and ID tokens.
Answer
The correct operational sequence is: 1) Client generates the secret code_verifier and computes the code_challenge, 2) Client redirects user to IdP authorization endpoint with the code_challenge, 3) IdP authenticates user and issues an authorization code bound to the code_challenge, 4) Client sends authorization code and plaintext code_verifier to IdP token endpoint, 5) IdP verifies code_verifier against code_challenge and issues access tokens.
Proof Key for Code Exchange (PKCE) mitigates authorization code interception attacks on public clients. The client first creates a secret code_verifier and calculates the code_challenge. Next, it sends the user to the IdP authorization endpoint carrying the code_challenge. After successful user authentication, the IdP returns an authorization code. The client then exchanges this authorization code by sending the plaintext code_verifier directly to the token endpoint. Finally, the IdP verifies that SHA-256 hashing of the code_verifier matches the code_challenge stored during authorization before issuing access and ID tokens.
Step-by-Step Solution
Key Concept
OAuth 2.0 Authorization Code Flow with PKCE (Proof Key for Code Exchange)
Estimated Time:1m 30s