Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where I should store code_verifier (oauth 2.0 code authorization flow with PKCE)

I'm currently working on an oauth 2.0 code authorization grant with PKCE in an SSR page (working with React in the front and Express in the back).

Where I should store code_verifier when client request to authorization server code (when authorization server creates code_challenge and code_verifier for verify latter). I have the authorization server running in an independent stack/infrastructure.

I should store code_verifier in req.headers ? (see Draft Campbell OAuth TBPKCE-00)

We are following RFC6749

like image 297
elaineee Avatar asked Jun 03 '19 15:06

elaineee


People also ask

Where is OAuth2 token stored?

Tokens received from OAuth providers are stored in a Client Access Token Store. You can configure client access token stores under the Libraries > OAuth2 Stores node in the Policy Studio tree view.

What is authorization code flow with PKCE?

The Authorization Code Flow + PKCE is an OpenId Connect flow specifically designed to authenticate native or mobile application users. This flow is considered best practice when using Single Page Apps (SPA) or Mobile Apps. PKCE, pronounced “pixy” is an acronym for Proof Key for Code Exchange.

What should the authorization code flow be used with?

Use the auth code flow paired with Proof Key for Code Exchange (PKCE) and OpenID Connect (OIDC) to get access tokens and ID tokens in these types of apps: Single-page web application (SPA) Standard (server-based) web application. Desktop and mobile apps.

Does Google OAuth support PKCE?

Google supports the Proof Key for Code Exchange (PKCE) protocol to make the installed app flow more secure.


1 Answers

I would suggest you to think about storing it in cookies, it is an easy way and it is not a really big deal if someone sees it. You can use the cookie-parser library for Node.js, which I personally really like and use almost daily, as it provides developer-friendly tools.

FYI: I am working on mainly on GraphQL APIs, and I find a good solution also to store the code_verifier in the context of the GraphQL Server, e.g. Apollo Server.

like image 187
georgekrax Avatar answered Oct 06 '22 01:10

georgekrax