dify/api/models
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
..
utils chore(api): Upgrade graphon to v0.5.1 (#37168) 2026-06-11 07:37:27 +00:00
__init__.py Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-02 21:56:53 +08:00
_workflow_exc.py
account.py fix(auth): normalize Gmail registration emails (#41249) 2026-08-26 07:14:27 +00:00
agent_config_entities.py fix: validate rule for provider scoped credentials (#41659) 2026-09-02 10:07:44 +00:00
agent.py refactor(agent): remove Agent Drive (#40887) 2026-08-19 06:34:36 +00:00
api_based_extension.py
base.py docs: correct UUIDv7 helper docstring (#41419) 2026-08-28 02:26:40 +00:00
comment.py refactor: pass session to workflow comment account accessors (#41117) 2026-08-24 03:20:32 +00:00
credential_permission.py feat: per-credential visibility control for plugin credentials (#35468) 2026-06-01 05:56:18 +00:00
dataset.py refactor(models): remove legacy db.session property wrappers on Dataset (#41569) 2026-09-01 06:28:24 +00:00
engine.py
enums.py feat(knowledge-fs): scope dataset API keys by knowledge base type 2026-09-03 05:59:39 -04:00
execution_extra_content.py refactor: migrate execution extra content repository tests from mocks to testcontainers (#33852) 2026-03-23 17:32:11 +09:00
human_input.py chore(api): upgrade graphon to v0.6.0, migrate HITL logic back to Dify (#38247) 2026-07-03 03:45:21 +00:00
knowledge_fs_cleanup.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
knowledge_fs_cutover.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
knowledge_fs.py feat(knowledge-fs): Legacy knowledge base allows multiple migrations 2026-08-19 13:21:52 +08:00
model.py feat(knowledge-fs): scope dataset API keys by knowledge base type 2026-09-03 05:59:39 -04:00
oauth.py feat: per-credential visibility control for plugin credentials (#35468) 2026-06-01 05:56:18 +00:00
onboarding.py feat(web): add step-by-step tour shell (#38785) 2026-07-20 09:23:25 +00:00
provider_ids.py ci: add flag for linter (#37018) 2026-06-08 04:53:12 +00:00
provider.py ci: add flag for linter (#37018) 2026-06-08 04:53:12 +00:00
skill.py feat: support agent skill (#39675) 2026-08-24 05:29:14 +00:00
snippet.py feat: snippet (#37046) 2026-06-05 09:38:42 +00:00
source.py refactor: replace bare dict with dict[str, Any] in models, providers, extensions, libs, and test utilities (#35186) 2026-04-14 17:51:25 +00:00
task.py
tools.py feat(api): add MCP user-identity forwarding (#36839) 2026-06-08 04:32:11 +00:00
trigger.py refactor(models): dep-inject Session on remaining @property accessors (#40797) 2026-08-18 07:23:09 +00:00
types.py chore: port isinstance to match case (#37271) 2026-06-18 00:18:03 +00:00
web.py refactor(models): dep-inject Session on remaining @property accessors (#40797) 2026-08-18 07:23:09 +00:00
workflow.py refactor(models): pass session into Workflow accessors (#41464) 2026-08-29 14:28:15 +00:00