Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding explanation for editing permissions 20230825 #6606

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b574c9e
adding explination for editing permissions
leanneeliatra Mar 6, 2024
3f32e80
changed to a h3 to see if review dog will accept
leanneeliatra Mar 6, 2024
289943a
Update _security/access-control/document-level-security.md
leanneeliatra Mar 7, 2024
7195c42
Update _security/access-control/document-level-security.md
leanneeliatra Mar 7, 2024
a918857
Update _security/access-control/document-level-security.md
leanneeliatra Mar 7, 2024
5c88efa
Update _security/access-control/document-level-security.md
leanneeliatra Mar 11, 2024
b05db06
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 13, 2024
97ba3c9
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 15, 2024
e839012
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 19, 2024
9dde189
Updates to both the users roles and DLS sections to reflect need to a…
leanneeliatra Mar 19, 2024
7a29048
updating after reviewdog comments
leanneeliatra Mar 19, 2024
2864a8d
updating roles in OpenSearch updates
leanneeliatra Mar 19, 2024
7bfc487
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 20, 2024
0340211
Merge branch 'main' into 20230825-edit-document-level-permissions
Naarcha-AWS Mar 21, 2024
a33218b
Apply suggestions from code review
leanneeliatra Mar 22, 2024
09a6e06
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 22, 2024
c4cca6b
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 26, 2024
c4f265e
Apply suggestions from code review
Naarcha-AWS Mar 26, 2024
cb681ae
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 27, 2024
af79721
Apply suggestions from code review
Naarcha-AWS Mar 27, 2024
24afe20
Update document-level-security.md
Naarcha-AWS Mar 27, 2024
415786f
Update _security/access-control/document-level-security.md
leanneeliatra Mar 27, 2024
6afb195
Merge branch 'main' into 20230825-edit-document-level-permissions
leanneeliatra Mar 27, 2024
06065f6
Merge branch 'main' into 20230825-edit-document-level-permissions
Naarcha-AWS Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions _security/access-control/document-level-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,33 @@ redirect_from:

# Document-level security (DLS)

Document-level security lets you restrict a role to a subset of documents in an index. The easiest way to get started with document- and field-level security is to open OpenSearch Dashboards and choose **Security**. Then choose **Roles**, create a new role, and review the **Index permissions** section.

![Document- and field-level security screen in OpenSearch Dashboards]({{site.url}}{{site.baseurl}}/images/security-dls.png)


## Simple roles

Document-level security uses the OpenSearch query DSL to define which documents a role grants access to. In OpenSearch Dashboards, choose an index pattern and provide a query in the **Document level security** section:

```json
{
"bool": {
"must": {
"match": {
"genres": "Comedy"
}
}
}
}
```

This query specifies that for the role to have access to a document, its `genres` field must include `Comedy`.

A typical request to the `_search` API includes `{ "query": { ... } }` around the query, but in this case, you only need to specify the query itself.
Document-level security lets you restrict a role to a subset of documents in an index.
For more information about users and roles in OpenSearch[, see the documentation.](https://opensearch.org/docs/latest/security/access-control/users-roles/#create-roles)
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

The easiest way to get started with document- and field-level security is:
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
1. Open OpenSearch Dashboards
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
2. Choose **Security**
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
3. Choose **Roles**
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
4. Create a new role
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
5. Review the **Index permissions** section
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are users looking for as they review the Index permissions section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside the 'index permissions' area/heading, is the DSL multiline text box, so it was just a step to get to the DSL area.

leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
6. Add document-level security with the addition of a DSL query to the `Document level security - optional` section
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
- For example, the following DSL could be added in the `Document level security - optional` text box.
Naarcha-AWS marked this conversation as resolved.
Show resolved Hide resolved
- This query specifies that for the role to have access to a document, its `genres` field must include `Comedy`
- A typical request to the `_search` API includes `{ "query": { ... } }` around the query, but in this case, you only need to specify the query itself.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following this bulleted list. It appears to contain content duplicated from above, and the structure doesn't work in terms of introducing the query.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A typical request to the `_search` API includes `{ "query": { ... } }` around the query, but in this case, you only need to specify the query itself.
- A typical request to the `_search` API includes `{ "query": { ... } }` around the query, but, in this case, you only need to specify the query itself.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can likely just remove this bulleted list.

```json
{
"bool": {
"must": {
"match": {
"genres": "Comedy"
}
}
}
}
```
- ![Document- and field-level security screen in OpenSearch Dashboards]({{site.url}}{{site.baseurl}}/images/security-dls.png)
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

## Updating roles by accessing the Rest API
Naarcha-AWS marked this conversation as resolved.
Show resolved Hide resolved

In the REST API, you provide the query as a string, so you must escape your quotes. This role allows a user to read any document in any index with the field `public` set to `true`:

Expand Down
31 changes: 31 additions & 0 deletions _security/access-control/users-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@

Roles are the core way of controlling access to your cluster. Roles contain any combination of cluster-wide permissions, index-specific permissions, document- and field-level security, and tenants. Then you map users to these roles so that users gain those permissions.

## Creating and Editing OpenSearch Roles - Overview

Check failure on line 17 in _security/access-control/users-roles.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.HeadingCapitalization] 'Creating and Editing OpenSearch Roles - Overview' is a heading and should be in sentence case. Raw Output: {"message": "[OpenSearch.HeadingCapitalization] 'Creating and Editing OpenSearch Roles - Overview' is a heading and should be in sentence case.", "location": {"path": "_security/access-control/users-roles.md", "range": {"start": {"line": 17, "column": 4}}}, "severity": "ERROR"}
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

OpenSearch roles can be updated using various methods, the three methods to add or edit roles are as follows.
Naarcha-AWS marked this conversation as resolved.
Show resolved Hide resolved

### Using the API:
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
Users can make HTTP requests to endpoints provided by OpenSearch to update security roles, permissions, and associated settings. This method offers granular control and automation capabilities for managing roles.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

### Using the UI (OpenSearch Dashboards):
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
OpenSearch Dashboards provides a user-friendly interface for managing roles. Navigate to the Security section within OpenSearch Dashboard where the roles, permissions, and document-level security settings can be configured. When updating the roles via the UI, the UI calls the API in the background to implement these changes.

Check warning on line 25 in _security/access-control/users-roles.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.LatinismsSubstitution] Use 'using, through, by accessing, or by choosing' instead of 'via'. Raw Output: {"message": "[OpenSearch.LatinismsSubstitution] Use 'using, through, by accessing, or by choosing' instead of 'via'.", "location": {"path": "_security/access-control/users-roles.md", "range": {"start": {"line": 25, "column": 249}}}, "severity": "WARNING"}
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

### Editing the YAML Configuration File:

Check failure on line 27 in _security/access-control/users-roles.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.HeadingCapitalization] 'Editing the YAML Configuration File:' is a heading and should be in sentence case. Raw Output: {"message": "[OpenSearch.HeadingCapitalization] 'Editing the YAML Configuration File:' is a heading and should be in sentence case.", "location": {"path": "_security/access-control/users-roles.md", "range": {"start": {"line": 27, "column": 5}}}, "severity": "ERROR"}
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
For users comfortable with configuration files and prefer a text-based approach, editing the YAML configuration file directly is an option. Roles and their associated permissions can be defined or modified within the roles.yml file. This method provides direct access to the underlying configuration and can be version-controlled for collaborative development environments.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
More information on **Creating Roles** can be found in the [Create Roles documentation][https://opensearch.org/docs/latest/security/access-control/users-roles/#create-roles)
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

Unless you need to create new [reserved or hidden users]({{site.url}}{{site.baseurl}}/security/access-control/api/#reserved-and-hidden-resources), we **highly** recommend using OpenSearch Dashboards or the REST API to create new users, roles, and role mappings. The `.yml` files are for initial setup, not ongoing use.
{: .warning }

Expand Down Expand Up @@ -75,6 +89,23 @@

See [Create role]({{site.url}}{{site.baseurl}}/security/access-control/api/#create-role).

## Edit Roles

Check failure on line 92 in _security/access-control/users-roles.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.HeadingCapitalization] 'Edit Roles' is a heading and should be in sentence case. Raw Output: {"message": "[OpenSearch.HeadingCapitalization] 'Edit Roles' is a heading and should be in sentence case.", "location": {"path": "_security/access-control/users-roles.md", "range": {"start": {"line": 92, "column": 4}}}, "severity": "ERROR"}
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

### OpenSearch Dashboards

1. Choose **Security**, **Roles**, and under **Create role**, select **Explore existing roles**.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
1. Given you are logged in with the correct admin permissions for editing the role, select the role from the list you would like to edit.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
1. Choose 'edit role' on the top right

Check warning on line 98 in _security/access-control/users-roles.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.DirectionTopBottom] Use 'upper right' instead of 'top right' for window, page, or pane references to features or controls. Use 'top' and 'bottom' only as a general screen reference. Raw Output: {"message": "[OpenSearch.DirectionTopBottom] Use 'upper right' instead of 'top right' for window, page, or pane references to features or controls. Use 'top' and 'bottom' only as a general screen reference.", "location": {"path": "_security/access-control/users-roles.md", "range": {"start": {"line": 98, "column": 30}}}, "severity": "WARNING"}
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
1. Update the role as required.
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved
1. Choose **Update** to save
leanneeliatra marked this conversation as resolved.
Show resolved Hide resolved

### roles.yml

See [YAML files]({{site.url}}{{site.baseurl}}/security/configuration/yaml/#rolesyml).

### REST API

See [Create role]({{site.url}}{{site.baseurl}}/security/access-control/api/#create-role).

## Map users to roles

Expand Down
Loading