Add general_access field on sharing doc to store a single access level for general access#6033
Open
cwperks wants to merge 8 commits intoopensearch-project:mainfrom
Open
Add general_access field on sharing doc to store a single access level for general access#6033cwperks wants to merge 8 commits intoopensearch-project:mainfrom
cwperks wants to merge 8 commits intoopensearch-project:mainfrom
Conversation
…l for which resource is shared generally Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6033 +/- ##
==========================================
+ Coverage 73.79% 73.84% +0.04%
==========================================
Files 440 440
Lines 27259 27371 +112
Branches 4052 4083 +31
==========================================
+ Hits 20117 20213 +96
- Misses 5227 5234 +7
- Partials 1915 1924 +9
🚀 New features to boost your workflow:
|
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.
Description
Replaces the previous convention of using a
"*"wildcard in recipient lists to represent publicly shared resources with a dedicatedgeneral_accessfield on theShareWithobject.This field stores a single access level string (for example,
"read_only") at which the resource is accessible to everyone, mirroring the Google Docs model where a document has one public access level while named recipients can independently hold higher levels.Category
Refactoring, Enhancement
Why these changes are required
The wildcard approach was semantically ambiguous.
"*"in a users list looked like just another principal value, required special-case parsing logic inRecipients.fromXContent, and made it impossible to express "publicly readable but only Alice can write" without conflating the two concerns.The new field makes public sharing a first-class concept that is orthogonal to named-recipient sharing.
What is the old behavior before these changes?
Public sharing was represented by placing
"*"in a recipient list, for example:isPublic()scanned all recipient sets for the wildcard. Only one blanket public state was possible, with no access-level granularity.What is the new behavior after these changes?
A dedicated
general_accessfield onshare_withstores the single access level granted to everyone:Named recipients at other access levels are unaffected.
isPublic()becomes a direct field read. The"*"sentinel is also replaced by"public"in theall_shared_principalsindex field used for query matching.Note:
general_accesscannot be set to a share-capable level — the API rejects with 400 BAD_REQUEST any payload wheregeneral_accessresolves to includecluster:admin/security/resource/share. Enforced inShareRequest.Builder.rejectSharePermissionOnGeneralAccess.API Examples
Set general access (PUT) — everyone can read, Alice can write:
Set general access only (PUT) — everyone can read:
Upgrade general access level (PUT) — replace read with read_write:
Set general access (PATCH) — set or upgrade the public access level:
Revoke general access (PATCH) — remove public access by setting to null:
GET sharing info response shape (after setting general access):
{ "sharing_info": { "resource_id": "<resource_id>", "resource_type": "<resource_type>", "created_by": { "user": "admin" }, "share_with": { "general_access": "read_only", "read_write": { "users": ["alice"] } } } }Issues Resolved
N/A
Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end?
No.
Testing
Unit tests in
ShareWithTestsandResourceSharingTestswere updated to reflect the new field.Integration tests in
PubliclySharedDocTestswere fully rewritten to cover:GETsharing info response correctly serializesgeneral_accessCheck List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.