Since PKCE is now the recommended method of authorisation over the implicit flow, I'm looking for best practice on handling code verifier and recommendations on how this might be done. On high level PKCE Authorisation flow consist of:
- Generate
code_verifier
on client side - Generate
code_challenge
from (1) - hit
/authorise
withcode_challenge
which redirect to select idp and in callback there's acode
- use
code
from (3) along withcode_verifier
to exchange for access token
Question is, in step 3, before the application redirect to authorisation server and then the idp, one has to store the code_verifier
somewhere. Where is that somewhere?
Seems like libraries like okta-oidc-js
store the code_verifier
in sessionStorage. Doesn't that expose you to XSS attack? i.e. if I was store the code_verifier
in sessionStorage before the application goes into the Authorisation flow and redirects, on the callback, what stops some rouge extension from reading the code
from the URL and code_verifier
from sessionStorage? Combination of which can be used to exchange for a access token.