dify/api/controllers/console
Jyong 79116d8c4b feat(knowledge-fs): scope dataset API keys by knowledge base type
Legacy knowledge bases (`datasets`) and KnowledgeFS spaces
(`knowledge_fs_control_spaces`) live in different tables, so a dataset API
key binding could only ever name a legacy dataset and the KnowledgeFS service
API never consulted bindings at all: a key scoped to specific knowledge bases
still reached every KnowledgeFS space in the workspace.

- Bindings carry a `resource_type` (`dataset` | `knowledge_fs_space`) and a
  nullable `control_space_id` (migration 9a4e7d1c2b60, existing rows stay
  `dataset`), with a CHECK that exactly one id column matches the type.
- `dataset_api_key_service` exposes the key scope by kind, validates and
  binds KnowledgeFS spaces (tenant-owned, not deleting/deleted), and cleans up
  keys scoped only to a space when its deletion is requested. The orphan-key
  cleanup is now NULL-safe so a space binding keeps a key alive.
- Legacy dataset routes only honour `dataset` bindings; the KnowledgeFS
  authorization service only honours `knowledge_fs_space` bindings and raises
  a scope error that the service API maps to 403 (unknown keys stay 401).
- Console key creation accepts `knowledge_space_ids`; list/create responses
  return them next to `dataset_ids`.
- The web scope picker lists KnowledgeFS spaces alongside legacy datasets
  when KnowledgeFS is enabled and submits the ids by kind; the scope column
  counts both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015zw5G5SX3HmVfnZof6YWAc
2026-09-03 05:59:39 -04:00
..
agent fix(rbac): let agent.manage operate every agent page (#41583) 2026-09-02 01:45:42 +00:00
app Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
auth refactor(api): extract account login service and consolidate adapters (#41184) 2026-09-03 06:20:21 +00:00
billing refactor(api): standardize compliance downloads (#41057) 2026-08-26 06:32:13 +00:00
datasets feat(knowledge-fs): scope dataset API keys by knowledge base type 2026-09-03 05:59:39 -04:00
explore refactor(api): centralize remote file handling (#41627) 2026-09-03 06:00:13 +00:00
knowledge_fs Merge remote-tracking branch 'origin/deploy/konwledge' into deploy/konwledge 2026-09-03 16:57:14 +08:00
snippets refactor(models): pass session into Workflow accessors (#41464) 2026-08-29 14:28:15 +00:00
socketio fix: prevent hidden-tab collaboration leader from saving stale drafts (#38997) 2026-07-20 06:58:01 +00:00
tag refactor(api): require active workspace in request context (#41280) 2026-09-02 06:54:47 +00:00
workspace Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
__init__.py Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-08-27 10:06:48 +08:00
admin.py chore: remove obsolete admin console routes (#35637) 2026-05-13 08:08:50 +00:00
apikey.py feat(knowledge-fs): scope dataset API keys by knowledge base type 2026-09-03 05:59:39 -04:00
error.py refactor(api): extract account login service and consolidate adapters (#41184) 2026-09-03 06:20:21 +00:00
extension.py refactor(console,web): dep-inject query params with @model_validate (#41646) 2026-09-03 01:50:22 +00:00
feature.py refactor(api): decouple system features and web adapters (#40772) 2026-09-01 11:50:52 +00:00
files.py refactor(console): inject file service (#41603) 2026-09-03 04:42:30 +00:00
flask_admission.py fix(rbac): let agent.manage operate every agent page (#41583) 2026-09-02 01:45:42 +00:00
human_input_form.py feat(workflow): support human input in loop and iteration (#39243) 2026-08-03 02:24:18 +00:00
init_validate.py refactor(api): extract init validation into layered application service (#40046) 2026-08-12 08:42:09 +00:00
notification.py refactor(api): decouple onboarding and notification services (#40759) 2026-08-31 04:37:07 +00:00
onboarding.py refactor(api): decouple onboarding and notification services (#40759) 2026-08-31 04:37:07 +00:00
remote_files.py refactor(api): centralize remote file handling (#41627) 2026-09-03 06:00:13 +00:00
setup.py refactor(api): extract init validation into layered application service (#40046) 2026-08-12 08:42:09 +00:00
spec.py refactor(api): decouple setup and spec endpoints (#40104) 2026-08-08 11:52:15 +00:00
system.py refactor(api): merge ping and version endpoints into system (#40058) 2026-08-10 08:50:40 +00:00
workflow_run_archive.py refactor(api): extract workflow run archive application service (#41253) 2026-08-27 02:41:43 +00:00
wraps.py refactor(api): decouple system features and web adapters (#40772) 2026-09-01 11:50:52 +00:00