Skip to content

Commit d672123

Browse files
Adds readme doc for share API usage
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent 4b0fb80 commit d672123

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ OpenSearch Security is a plugin for OpenSearch that offers encryption, authentic
2222
- [Installation](#installation)
2323
- [Test and Build](#test-and-build)
2424
- [Config hot reloading](#config-hot-reloading)
25+
- [Resource Sharing API](#resource-sharing-api)
2526
- [Onboarding new APIs](#onboarding-new-apis)
2627
- [System Index Protection](#system-index-protection)
2728
- [Contributing](#contributing)
@@ -113,6 +114,149 @@ The Security Plugin configuration is stored in a dedicated index in OpenSearch i
113114
* Configuration changes do not require a restart
114115
* Configuration changes take effect immediately
115116

117+
## Resource Sharing API
118+
119+
The Security Plugin, starting v3.2.0, introduces a share API that can be used by opensearch-dashboards and/or REST client to enable resource-owners to share their resources. A resource is currently defined as a document in an index. The feature grants creators of the document access to share it with other entities, i.e., users, roles or backend_roles.
120+
The feature is proposed in this GitHub issue: https://github.com/opensearch-project/security/issues/4500
121+
122+
The API supports 3 HTTP methods:
123+
124+
### 1. `PUT /_plugins/_security/api/resource/share`
125+
126+
**Description:**
127+
Share a resource with users, roles, or backend roles at specific access levels.
128+
This **replaces** any existing sharing configuration.
129+
130+
**Request Body:**
131+
132+
```json
133+
{
134+
"resource_id": "resource-123",
135+
"resource_index": "my-resource-index",
136+
"share_with": {
137+
"read_only": {
138+
"users": ["alice"],
139+
"roles": ["readers"],
140+
"backend_roles": ["data-readers"]
141+
},
142+
"read_write": {
143+
"users": ["bob"]
144+
}
145+
}
146+
}
147+
```
148+
149+
**Success Response:**
150+
151+
```json
152+
{
153+
"sharing_info": {
154+
"resource_id": "resource-123",
155+
"created_by": { "username": "admin" },
156+
"share_with": {
157+
"read_only": {
158+
"users": ["alice"],
159+
"roles": ["readers"],
160+
"backend_roles": ["data-readers"]
161+
},
162+
"read_write": {
163+
"users": ["bob"]
164+
}
165+
}
166+
}
167+
}
168+
```
169+
170+
### 2. `PATCH /_plugins/_security/api/resource/share`
171+
172+
**Description:**
173+
**Adds** and/or **removes** recipients from access levels.
174+
Does **not** overwrite the entire sharing configuration.
175+
176+
**Request Body:**
177+
178+
```json
179+
{
180+
"resource_id": "resource-123",
181+
"resource_index": "my-resource-index",
182+
"patch": {
183+
"share_with": {
184+
"read_only": {
185+
"users": ["charlie"]
186+
}
187+
},
188+
"revoke": {
189+
"read_only": {
190+
"users": ["alice"]
191+
},
192+
"read_write": {
193+
"users": ["bob"]
194+
}
195+
}
196+
}
197+
}
198+
```
199+
200+
**Success Response:**
201+
202+
```json
203+
{
204+
"sharing_info": {
205+
"resource_id": "resource-123",
206+
"created_by": { "username": "admin" },
207+
"share_with": {
208+
"read_only": {
209+
"users": ["charlie"],
210+
"roles": ["readers"],
211+
"backend_roles": ["data-readers"]
212+
},
213+
"read_write": {}
214+
}
215+
}
216+
}
217+
```
218+
219+
**Allowed Patch Keys:**
220+
221+
* `"share_with"`
222+
* `"revoke"`
223+
224+
225+
### 3. `GET /_plugins/_security/api/resource/share?resource_id=<id>&resource_index=<index>`
226+
227+
**Description:**
228+
Returns the current sharing configuration for a resource.
229+
230+
**Query Parameters:**
231+
232+
* `resource_id` (required)
233+
* `resource_index` (required)
234+
235+
**Example Request:**
236+
237+
```
238+
GET /_plugins/_security/api/resource/share?resource_id=resource-123&resource_index=my-resource-index
239+
```
240+
241+
**Success Response:**
242+
243+
```json
244+
{
245+
"sharing_info": {
246+
"resource_id": "resource-123",
247+
"created_by": { "username": "admin" },
248+
"share_with": {
249+
"read_only": {
250+
"users": ["charlie"],
251+
"roles": ["readers"],
252+
"backend_roles": ["data-readers"]
253+
},
254+
"read_write": {}
255+
}
256+
}
257+
}
258+
```
259+
116260
## Onboarding new APIs
117261

118262
It is common practice to create new transport actions to perform different tasks between nodes when developing new APIs. For any new or existing plugins that want to onboard & integrate these actions with security, they should follow the steps below:

0 commit comments

Comments
 (0)