Skip to content

Commit f377702

Browse files
authored
[Docs] Add flows for OBO and Service Account (opensearch-project#3052)
As we are expanding the features in the Security Plugin we are capturing how those features work in our service architecture. For this set of changes I'm documenting how plugins, extensions with OnBehalfOf tokens, and Extension with service accounts interact with the cluster. Bonus added a table of contents Signed-off-by: Peter Nied <[email protected]>
1 parent 37639cd commit f377702

File tree

2 files changed

+138
-32
lines changed

2 files changed

+138
-32
lines changed

ARCHITECTURE.md

+137
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
- [OpenSearch Security Plugin Architecture](#opensearch-security-plugin-architecture)
2+
- [Components](#components)
3+
- [Security Plugin](#security-plugin)
4+
- [Security Configuration](#security-configuration)
5+
- [Configuration Files](#configuration-files)
6+
- [Admin Tools](#admin-tools)
7+
- [Flows](#flows)
8+
- [Authentication / Authorization](#authentication--authorization)
9+
- [Multiple Authorization Provider flow](#multiple-authorization-provider-flow)
10+
- [Rest vs Transport flow](#rest-vs-transport-flow)
11+
- [Plugin Authorization Flows](#plugin-authorization-flows)
12+
- [Extension On Behalf Of Authorization Flows](#extension-on-behalf-of-authorization-flows)
13+
- [Extension Service Account Authorization](#extension-service-account-authorization)
14+
115
# OpenSearch Security Plugin Architecture
216

317
OpenSearch’s core systems do not include security features, these features are added by installing the Security Plugin. The Security Plugin extends OpenSearch to provide authentication, authorization, end to end Encryption, audit logging, and management interfaces.
@@ -129,3 +143,126 @@ sequenceDiagram
129143
AH-->>O: Result
130144
O->>C: Response
131145
```
146+
147+
#### Plugin Authorization Flows
148+
149+
Plugins that implement ActionPlugin can register REST and Transport layer handlers which can receive requests from the user and other nodes in the cluster, respectively. During the lifecycle of an incoming requests there are two standard ways to handle authorized actions in these flows. One us to use the authenticated user, the other is to run outside the user context.
150+
151+
As in the normal authorization flow into the service the user is authenticated, then the action is determined, and finally an authorization check for the user is performed, and they are allowed or denied. This can be thought of as running on behalf of the user.
152+
153+
There are some actions run by plugins that do not reuse the authentication or authorization of the current user, such as to make changes to internal cluster state for cross cluster replication. When requests come in for these actions they are run outside the user context.
154+
155+
> Operating outside the user context means that no authorization checks are performed. This is used to elevate plugin activities such as modifications to system indices, operations on the cluster configuration, and to ensure actions on the cluster are not associated with a singular user.
156+
157+
```mermaid
158+
sequenceDiagram
159+
title Authorization during action flow for Plugins
160+
autonumber
161+
participant C as Client
162+
participant OS as OpenSearch
163+
participant SP as SecurityPlugin
164+
participant P as Plugin
165+
166+
C->>OS: Request
167+
OS->>SP: Request
168+
SP->>SP: Add Auth information to request context
169+
OS->>P: Client Request
170+
P->>SP: Execute transport layer action
171+
SP->>SP: Check if action is allowed
172+
alt Allowed
173+
SP->>OS: Continue request
174+
OS-->>P: Transport layer action result
175+
else Denied
176+
SP-->>OS: Return 403 Forbidden
177+
OS-->>C: 403 Forbidden
178+
end
179+
alt Plugin run outside user context
180+
P->>P: Stash context
181+
P->>SP: Execute transport layer action outside user context
182+
SP-->>SP: Check if action is allowed
183+
SP->>OS: Continue request
184+
OS-->>P: Transport layer action result
185+
P->>P: Restore user context
186+
end
187+
P-->>SP: Result
188+
SP-->>OS: Result
189+
OS-->>C: Result
190+
```
191+
192+
#### Extension On Behalf Of Authorization Flows
193+
194+
Extensions will be able to operate in similar flows as Plugins to ensure authorization is correctly handled. Registration of REST handlers is allowed and transport layer actions are not permitted. After the request has been authorized for the user to be transmitted to the extension the token generator will create a just in time token for use with that request on behalf of the user.
195+
196+
> On Behalf Of tokens are an optional feature, while supported through the extensions API it needs to be enabled on an individual extension basis. Issuing On Behalf Of tokens can be disabled which will alter request forward to the extension not to include the On Behalf Of token.
197+
198+
```mermaid
199+
sequenceDiagram
200+
title Authorization during action flow for Extension
201+
autonumber
202+
participant C as Client
203+
participant OS as OpenSearch
204+
participant SP as SecurityPlugin
205+
participant E as Extension
206+
207+
C->>OS: Request
208+
OS->>SP: Request
209+
SP->>SP: Add Auth information from request context
210+
alt Allowed
211+
SP->>OS: Continue request
212+
OS-->>SP: Generate OnBehalfOf token for extension
213+
SP->>OS: Return OnBehalfOf token
214+
OS-->>E: Forward client Request with OnBehalfOf token
215+
else Denied
216+
note over E: Extension does not know<br>about denied requests
217+
SP-->>OS: Access denied
218+
OS-->>C: 403 Forbidden
219+
end
220+
221+
E->>OS: Call OpenSearch REST API<br>with OnBehalfOf token
222+
OS->>SP: Request
223+
SP->>SP: Add Auth information from OnBehalfOf token
224+
alt Allowed
225+
SP->>OS: Continue request
226+
OS-->>E: Return REST API Action
227+
E->>OS: Return extension response
228+
OS->>C: Result
229+
else Denied
230+
SP-->>OS: Access denied
231+
OS-->>E: 403 Forbidden
232+
note over E: Extension responsible to understand<br>communicate failure response(s)
233+
E->>OS: Return extension response
234+
OS->>C: Result
235+
end
236+
```
237+
238+
#### Extension Service Account Authorization
239+
240+
Service account information is provided to the extension on initialization. This allows extension to make requests against the OpenSearch Cluster without needing an incoming request. Since this request is down in the context of a different identity it can have different permissions from that of an On Behalf Of user such as modification to a persistent data store used by the extension.
241+
242+
```mermaid
243+
sequenceDiagram
244+
title Authorization with Service Account
245+
autonumber
246+
participant C as Client
247+
participant E as Extension
248+
participant OS as OpenSearch
249+
participant SP as SecurityPlugin
250+
251+
OS->>OS: Initialize Extensions
252+
OS->>SP: Register extension service account
253+
SP->>OS: Service account token
254+
OS->>E: Initialization extension<br>include Service account token
255+
Note over E: Extension is initalized
256+
C->>E: Request
257+
E->>OS: Check extension data store<br>include Service account token
258+
OS->>SP: Request
259+
SP->>SP: Add Auth information from request context
260+
alt Allowed
261+
SP->>OS: Continue request
262+
OS->>E: REST API Result
263+
else Denied
264+
SP->>OS: Access denied
265+
OS->>E: 403 Forbidden
266+
end
267+
E->>C: Return extension response
268+
```

README.md

+1-32
Original file line numberDiff line numberDiff line change
@@ -120,38 +120,7 @@ It is common practice to create new transport actions to perform different tasks
120120
2. Register the action in the [OpenSearch Security plugin](https://github.com/opensearch-project/security). Each new action is registered in the plugin as a new permission. Usually, plugins will define different roles for their plugin (e.g., read-only access, write access). Each role will contain a set of permissions. An example of adding a new permission to the `anomaly_read_access` role for the [Anomaly Detection plugin](https://github.com/opensearch-project/anomaly-detection) can be found in [this PR](https://github.com/opensearch-project/security/pull/997/files).
121121
3. Register the action in the [OpenSearch Dashboards Security plugin](https://github.com/opensearch-project/security-dashboards-plugin). This plugin maintains the full list of possible permissions, so users can see all of them when creating new roles or searching permissions via Dashboards. An example of adding different permissions can be found in [this PR](https://github.com/opensearch-project/security-dashboards-plugin/pull/689/files).
122122

123-
```mermaid
124-
sequenceDiagram
125-
participant Client
126-
participant OpenSearch
127-
participant SecurityPlugin
128-
participant Cluster as Plugin
129-
130-
Client->>OpenSearch: Request
131-
OpenSearch->>SecurityPlugin: Request
132-
SecurityPlugin->>SecurityPlugin: Add Auth information to request context
133-
OpenSearch->>Cluster: Client Request
134-
Cluster->>SecurityPlugin: Execute transport layer action
135-
SecurityPlugin->>SecurityPlugin: Check if action is allowed
136-
alt Allowed
137-
SecurityPlugin->>OpenSearch: Continue request
138-
OpenSearch-->>Cluster: Transport layer action result
139-
else Denied
140-
SecurityPlugin-->>OpenSearch: Return 403 Forbidden
141-
OpenSearch-->>Client: 403 Forbidden
142-
end
143-
alt Plugin run outside user context
144-
Cluster->>Cluster: Stash context
145-
Cluster->>SecurityPlugin: Execute transport layer action outside user context
146-
SecurityPlugin-->>SecurityPlugin: Check if action is allowed
147-
SecurityPlugin->>OpenSearch: Continue request
148-
OpenSearch-->>Cluster: Transport layer action result
149-
Cluster->>Cluster: Restore user context
150-
end
151-
Cluster-->>SecurityPlugin: Result
152-
SecurityPlugin-->>OpenSearch: Result
153-
OpenSearch-->>Client: Result
154-
```
123+
See the [plugin-authorization-flows](ARCHITECTURE.md#plugin-authorization-flows) in the ARCHITECTURE.md.
155124

156125
### System Index Protection
157126

0 commit comments

Comments
 (0)