Pixy tokens for public clients
PKCE ("pixy"),an extension of Authorization Grant Type of OAuth 2.0, is now recommended for Single-Page Applications (public clients) and mobile apps where access tokens might be intercepted.
Implicit grant type , which was typically used for these types of apps, has some security concerns.
Remember:
Client==Application
Resource Owner==User
Confidential Clients (running on server) = can securely store secrets
Public Client (running in browser/SPA/mobile apps) = cannot store secrets securely
PKCE Flow:
- The Proof Key for Code Exchange (PKCE) extension requires the calling application to generate a cryptographically random code verifier and a BASE64 encoded hash (SHA256) of code verifier called the code challenge on the fly before initiating the authorization flow.
- Application adds the code challenge to the request going to the authorization server to get the authorization code. Authorization server stores the code challenge and sends a one time us authorization code.
- The application then sends the authorization code received along with the original code verifier to get an id and access token.
- Authorization server before issuing the tokens, validates whether the code verifier received in the request matches the code challenge sent earlier in step 2.
- Application requests data from API using access token.
Attackers can intercept the Authorization Code but cannot exchange it for tokens without the code verifier.
Use SDKs provided by Okta, Auth0, forgerock to implement this flow in your apps.
Comments
Post a Comment