Menu

OAuth sign-in with a BFF: redirects and PKCE explained
📰

OAuth sign-in with a BFF: redirects and PKCE explained

DEV Community: authentication·Renato D. Prado·11 days ago
#El6CnRBi
#devtoauthentication#devto#dev#code#browser
Long article (1805 words) — no AI summary yet.
Reading 0:00
15s threshold

In the previous article we saw how CSRF works and how OAuth's state parameter stops an attacker from signing you into their account. But state is not the only thing that can go wrong in an OAuth sign-in. This article covers the next one: a stolen authorization code , and the tool that stops it, PKCE, with its verifier and challenge . Along the way we'll answer two questions that confuse almost everyone the first time: what a 302 really does, and why the server can't simply call the identity provider itself.

This time the app has a BFF (backend for frontend): a small server that sits between the browser and everything else. A BFF is not required for the sign-in to work : a single-page app can run the whole sign-in by itself, with the same state and PKCE. But it makes it safer : the secrets stay on the server, the browser only gets an HttpOnly session cookie holding a random id, and as a server the BFF can hold a client secret, which a browser can't.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.