fix(permission): scope system-model defaults to the binding's column (IKBA8U) - #2380
Open
yaojin3616 wants to merge 1 commit into
Open
fix(permission): scope system-model defaults to the binding's column (IKBA8U)#2380yaojin3616 wants to merge 1 commit into
yaojin3616 wants to merge 1 commit into
Conversation
…(IKBA8U) A space-level ``viewer`` binding leaked ``view_file`` on every file in the space, so the knowledge QA retrieval filter surfaced chunks the user could not browse from the listing UI. Root cause: ``FineGrainedPermissionService._permission_ids_for_relation`` called ``default_permission_ids_for_relation`` for any system-model default, which returns every level-1 permission across the three columns (space / folder / file). With ``nearest_binding_wins=True`` the lineage walk stopped at the space-level binding and handed the file the full level-1 set, including ``view_file``. Add ``column_permission_ids_for_relation`` on the knowledge-space template, which returns the matching column only (with the transitive folder->file grant preserved so the F036 listing UI keeps working), and route the lineage-walk path through it. ``default_permission_ids_for_relation`` is unchanged -- the public-space / membership fallback still relies on the cross-column default. Refs: IKBA8U
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix IKBA8U: a user with only a knowledge-space
viewerbinding (i.e.view_spaceonly) was gettingview_filegranted on every file inside the space, so the knowledge QA retrieval filter surfaced chunks the user could not browse from the listing UI.Root cause
FineGrainedPermissionService._permission_ids_for_relationcalleddefault_permission_ids_for_relationfor any system-model default. That helper flattens every level-1 permission across the three columns (space / folder / file). Withnearest_binding_wins=Truethe lineage walk stopped at the space-level binding and handed the file the full level-1 set — includingview_file. The QA retrieval post-filter then had no way to distinguish a real per-file grant from the inherited space-level grant, so the file leaked through.Fix
column_permission_ids_for_relationon the knowledge-space permission template, which returns the matching column only (with the transitive folder→file grant preserved so the F036 listing UI keeps working).is_systemmodel default) in_permission_ids_for_relationthrough it forknowledge_space/folder/knowledge_file.default_permission_ids_for_relationis unchanged — the public-space / membership fallback (_public_space_viewer_permission_ids) still relies on the cross-column default.Behavior matrix
viewerview_space, view_folder, view_file, download_*view_spaceonlyviewerview_folder, download_folder, view_file, download_file(transitive)viewerview_file, download_fileonlypermissions[]permissions[])Verification
Added 13 tests across three files:
test/permission/test_ikba8u_view_file_column_scope.py— 10 tests: helper unit tests + real lineage-walk tests viaInMemoryOpenFGA.test/knowledge/test_ikba8u_bug_verify.py— 2 tests: the reproduction through the productionKnowledgeSpaceService._get_child_item_effective_permission_idspath, asserting the leak is gone.test/workstation/test_ikba8u_repro.py— 1 test: end-to-endqueryChunksFromDBreproduction confirming the QA path now returns 0 docs for a space-only viewer.Targeted tests (44 in total: F029 / F036 / IKBA8U) all green. Full
test/knowledge/,test/permission/,test/workstation/baselines unchanged: same set of pre-existing failures before and after the fix (the fix does not regress or fix any unrelated test).Refs
IKBA8U — 日常模式-检索知识空间,只有知识空间权限,没有知识空间下的文件权限。检索出来了