Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Back end-for-Front end: The most secure architecture for browser-based apps

The Backend-for-Frontend (BFF) architecture serves as a secure proxy for browser apps, keeping access tokens and secrets server-side to prevent client-side exposure. It addresses OAuth security concerns for single-page applications by shifting token handling from the browser to a backend component.

Background

- The Backend-for-Frontend (BFF) pattern means a dedicated server-side backend sits between a browser-based app (e.g., React, Vue, Angular) and downstream services like APIs or identity providers. Instead of the browser calling services directly, all requests go through this BFF. - The key security advantage in this article: the BFF keeps OAuth access tokens and client secrets server-side, never exposing them in browser JavaScript. This prevents token theft from XSS attacks or malicious browser extensions. - This contrasts with the more common "SPA (Single Page Application) + PKCE" flow, where tokens are handled in the browser's memory or storage and are thus more vulnerable to exfiltration. - The article argues that BFF is not just an architectural preference but a security requirement for browser-based apps handling user sessions, especially when using OAuth2/OIDC with confidential clients.

Related stories