|
| 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 | + |
1 | 15 | # OpenSearch Security Plugin Architecture
|
2 | 16 |
|
3 | 17 | 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
|
129 | 143 | AH-->>O: Result
|
130 | 144 | O->>C: Response
|
131 | 145 | ```
|
| 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 | +``` |
0 commit comments