Implement BFF OAuth2 Proxy
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- azure, fastapi, nginx, python, react, redis, typescript
- 领域
- api, authentication, backend, devops, frontend, infrastructure, security
调研方向
首先定位 Nginx、oauth2-proxy 和 FastAPI 的部署或配置入口,然后跟踪 /oauth2/* 和 /api/* 路由。检查 Microsoft Entra ID 令牌和由 Redis 支持的会话应如何工作。完成的标准是:经过身份验证的路由、安全的会话处理、令牌标头以及 FastAPI JWT 验证均符合要求。
由索引模型根据 Issue 内容生成。
描述
Describe Problem
The application requires secure authentication for the SPA frontend to communicate with the FastAPI backend API. Direct OAuth2 flows from the browser (implicit flow or authorization code with PKCE stored in browser) expose tokens to XSS attacks and require complex token management in the frontend. Without a Backend-for-Frontend (BFF) pattern, the frontend must handle token refresh, storage, and secure transmission, increasing attack surface and complexity.
Suggest Solution
Implement a BFF OAuth2 proxy using oauth2-proxy with the following architecture:
- Deploy oauth2-proxy as an intermediary between the SPA and backend API
- Configure OIDC authentication with Microsoft Entra ID (Azure AD)
- Use PKCE (
code_challenge_method: S256) for secure authorization code flow - Enable Redis-backed session storage for horizontal scalability
- Configure Nginx reverse proxy with
auth_requestdirective- Route
/oauth2/*paths directly to oauth2-proxy - Enforce authentication on
/api/*routes (return 401 if unauthenticated) - Redirect unauthenticated users to sign-in for all other routes
- Route
- Token injection via headers
- Inject
Authorization: Bearer <id_token>header for API requests - Forward
X-Auth-Request-Access-Tokenfor additional validation
- Inject
- Secure cookie configuration
cookie_secure: true,cookie_httponly: true,cookie_samesite: lax- 15-minute token refresh interval, 1-hour session expiry
- CSRF protection with per-request tokens
- Backend JWT validation in FastAPI
- Validate tokens against Azure AD JWKS endpoint
- Extract user claims (oid, name, email, roles) for authorization
Additional Details
- 主要语言
- TypeScript
- 星标
- 106
- 派生
- 15
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 29
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
equinor/template-fastapi-react 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
equinor/template-fastapi-react#702 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
equinor/template-fastapi-react#701 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
equinor/template-fastapi-react#438 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
equinor/template-fastapi-react#397 ·
维护者通常 1 天内回复
-
Update CI workflow (tests.yaml) to reflect pre-commit可能已有人在做 @mariuswinger 于 1612 天前认领。 未关闭type: :bulb: feature
equinor/template-fastapi-react#41 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 equinor/template-fastapi-react 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
super-productivity/super-productivity#12128 · 2 条评论 ·
维护者通常 1 天内回复
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at once可能已有人在做 @2389400626lh-ops 今天认领。 未关闭Area: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
难度 2/5 1-3 小时 新手友好度 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameter未关闭
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 1/5 1-3 小时 新手友好度 72/100
justyns/silverbullet-ai#199 ·