WeKnora/internal/middleware
wizardchen d2ffc1b973 refactor(api-keys): simplify authorization to a single-role gate
Redesign tenant API key authorization around one dimension (role) plus a
central default-deny gate, replacing the previous role + KB-scoped flag model.

- Add APIKeyGate as the single authority for API-key authorization: routes
  declare one policy (MinRole) via apiKeyGroup/apiKeyRoute helpers; undeclared
  routes are denied by default. JWT principals short-circuit the gate and the
  JWT-centric RBAC guards short-circuit for API-key principals.
- Roles: viewer/contributor/admin are knowledge-base data-plane only (KB scope
  is a pure downstream data filter); owner is a full-access tenant tier that
  unlocks tenant-level infrastructure routes and is required for every method.
- Drop the KBScoped policy flag and the KB-restricted-vs-tenant branching.
- Security hardening: never disclose HMAC secret (return presence only), abort
  writes on API-key encryption failure, deny KB-restricted keys on /files, and
  backfill legacy key hashes at startup instead of O(N) plaintext scans.
- Frontend: two-level create dialog (access type -> permission level), rename
  role labels to reflect actual scope, sync en/zh/ko/ru locales.
- Fix startup self-check false-positive on trailing-slash routes and normalize
  gin paths before comparison; add regression tests.
2026-07-07 12:00:13 +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
api_key_gate.go refactor(api-keys): simplify authorization to a single-role gate 2026-07-07 12:00:13 +08:00
api_key_gate_test.go refactor(api-keys): simplify authorization to a single-role gate 2026-07-07 12:00:13 +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 refactor(api-keys): simplify authorization to a single-role gate 2026-07-07 12:00:13 +08:00
auth_api_principal_test.go fix: harden API principal config after review 2026-06-30 20:01:05 +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: scope API MCP OAuth by principal 2026-06-30 20:01:05 +08:00
embed_auth_test.go fix(api-keys): harden scoped key auth after code review 2026-07-07 12:00:13 +08:00
error_handler.go init commit 2025-08-05 15:08:07 +08:00
kb_access.go test(api-keys): add tests for tenant API key management path rejection 2026-07-07 12:00:13 +08:00
kb_access_test.go fix(server): case-insensitive doc keyword search + not-found classification 2026-07-06 22:53:01 +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 refactor(api-keys): simplify authorization to a single-role gate 2026-07-07 12:00:13 +08:00
rbac_api_key_shortcircuit_test.go refactor(api-keys): simplify authorization to a single-role gate 2026-07-07 12:00:13 +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