WeKnora/internal/middleware
wizardchen 7f3f219f58 feat(mcp): add OAuth2 authorization for MCP services
Support connecting to MCP servers that require OAuth2, with a Cursor-like
zero-config flow: the user provides only a URL and the system performs
metadata discovery, dynamic client registration (DCR), and the
authorization code flow with PKCE on first connect.

- Persist per-user access/refresh tokens and per-service DCR client
  credentials, encrypted at rest (AES-256-GCM)
- Store the PKCE verifier/state during the flow via Redis with an
  in-memory fallback for Lite mode
- Cache MCP clients per (service, user) so tokens stay user-isolated
- Add endpoints for authorize-url, callback, status, and token revoke;
  the callback is allowlisted for unauthenticated access
- Surface a structured "authorization required" hint when a tool call
  hits an unauthorized MCP service
- Frontend: add an auth-type selector with OAuth config, inline
  authorization status/actions, and render the connection test result
  inline in the editor drawer instead of a stacked centered dialog
2026-06-22 20:19:31 +08:00
..
asynqdl fix: mark knowledge delete failures after retry exhaustion 2026-06-16 16:47:46 +08:00
access.go refactor(tenant_member): simplify tenant ID resolution in handlers 2026-05-18 17:28:58 +08:00
access_test.go refactor(tenant_member): simplify tenant ID resolution in handlers 2026-05-18 17:28:58 +08:00
audit_provider.go feat(rbac): per-tenant audit log for RBAC events (PR 6, #1303) 2026-05-18 17:28:58 +08:00
auth.go feat(mcp): add OAuth2 authorization for MCP services 2026-06-22 20:19:31 +08:00
auth_public_ratelimit.go feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
auth_role_test.go chore(rbac): update default behavior for tenant RBAC configuration 2026-05-18 21:24:28 +08:00
embed_auth.go feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
embed_auth_test.go feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
error_handler.go init commit 2025-08-05 15:08:07 +08:00
kb_access.go fix(wiki): clear stale citation chunks on deletion 2026-06-12 23:08:20 +08:00
kb_access_test.go fix(wiki): clear stale citation chunks on deletion 2026-06-12 23:08:20 +08:00
language.go fix(i18n): use WEKNORA_LANGUAGE env for prompt language fallback instead of hardcoded zh-CN 2026-04-02 12:01:25 +08:00
logger.go fix(middleware): mask camelCase secret fields in request logs 2026-05-12 19:27:29 +08:00
logger_test.go fix(middleware): mask camelCase secret fields in request logs 2026-05-12 19:27:29 +08:00
rbac.go feat(system-admin): implement revocation of system admin privileges with safeguards 2026-05-26 21:13:56 +08:00
rbac_audit_test.go feat(rbac): per-tenant audit log for RBAC events (PR 6, #1303) 2026-05-18 17:28:58 +08:00
rbac_test.go chore(rbac): update default behavior for tenant RBAC configuration 2026-05-18 21:24:28 +08:00
recovery.go fix: replace standard log with structured logger in main and recovery middleware 2026-02-06 17:59:15 +08:00