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

audit logging tests, named routes #7

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
599e608
Add .plugins-ml-connector to system index (#2947)
zane-neo Jul 7, 2023
47c4feb
Add password message to /dashboardsinfo endpoint (#2949)
cwperks Jul 7, 2023
092e8f5
Bump SAML libs (#2927)
willyborankin Jul 7, 2023
49cbf52
Remove commons-collections 3.2.2 (#2924)
willyborankin Jul 7, 2023
a53a8a6
Authorize rest requests (#2753)
DarshitChanpura Jul 7, 2023
7daf67a
Add dependandabot yml file (#2958)
willyborankin Jul 8, 2023
8e044a6
dependabot: bump org.apiguardian:apiguardian-api from 1.0.0 to 1.1.2 …
dependabot[bot] Jul 9, 2023
8227f64
dependabot: bump com.sun.istack:istack-commons-runtime (#2960)
dependabot[bot] Jul 9, 2023
9e6aab3
dependabot: bump com.google.j2objc:j2objc-annotations from 1.3 to 2.8…
dependabot[bot] Jul 9, 2023
4409701
Add readonly API to security plugin (#2966)
zane-neo Jul 10, 2023
8d636c4
Adds a check to skip serialization-deserialization if request is for …
DarshitChanpura Jul 10, 2023
0794c3f
dependabot: bump jakarta.xml.bind:jakarta.xml.bind-api (#2968)
dependabot[bot] Jul 10, 2023
99ff7b3
dependabot: bump org.apache.bcel:bcel from 6.6.0 to 6.7.0 (#2969)
dependabot[bot] Jul 10, 2023
1113244
Bump eventbus to 3.3.1 (#2965)
willyborankin Jul 10, 2023
06eed60
dependabot: bump org.glassfish.jaxb:jaxb-runtime from 2.3.4 to 4.0.3 …
dependabot[bot] Jul 10, 2023
9599155
Bump guava to 32.1.1-jre (#2976)
cwperks Jul 10, 2023
4a1ec53
Bump jaxb to 2.3.8 (#2977)
cwperks Jul 10, 2023
9a8b25c
Update Gradle to 8.2.1 (#2978)
reta Jul 10, 2023
e5348eb
Change maven repo location for compatibility check (#2980)
owaiskazi19 Jul 10, 2023
df07bea
SAML 4.3.0 addition persmission (#2987)
willyborankin Jul 11, 2023
0e6608d
Bump JSON libs (#2926)
willyborankin Jul 11, 2023
37aacdc
Update imports for files refactored in core PR #8157 (#3003)
cwperks Jul 17, 2023
8cb3829
Use SNAPSHOT in bwc tests to run tests with latest commits (#3024)
cwperks Jul 18, 2023
f1be2d7
Add release notes for 2.9.0.0 (#2992)
cwperks Jul 18, 2023
809aeda
add .plugins-ml-config in the system index (#2993)
Zhangxunmt Jul 18, 2023
744b5d4
add password regex setting onto dashboardsinfo backend call (#2999)
derek-ho Jul 18, 2023
ab6778d
Update ospackage, checker-qual, zcxvbn and error_prone_annotations, c…
cwperks Jul 19, 2023
59e2657
add workflow cluster permissions to alerting roles (#2994)
eirsep Jul 21, 2023
93ee2ba
Triage label guidelines (#3048)
peternied Jul 25, 2023
8063e1b
Adapt MediaType library change in core (#3050)
RyanL1997 Jul 25, 2023
6bac470
Clean up REST API (Part 1) (#2900)
willyborankin Jul 27, 2023
d3488e8
dependabot: bump kafka_version from 3.5.0 to 3.5.1 (#3041)
dependabot[bot] Jul 27, 2023
08d1734
Fix build after Lucene upgrade and breaking XContentFactory changes (…
cwperks Jul 31, 2023
cca77be
Remove static local-node reference (#3066)
DarshitChanpura Jul 31, 2023
c0e50da
dependabot: bump org.cryptacular:cryptacular from 1.2.4 to 1.2.5 (#3071)
dependabot[bot] Jul 31, 2023
2f69a10
bump com.github.wnameless.json:json-base from 2.4.0 to 2.4.1 (#3062)
cwperks Jul 31, 2023
5f62e8a
dependabot: bump commons-io:commons-io from 2.11.0 to 2.13.0 (#3074)
dependabot[bot] Aug 1, 2023
dca76cb
dependabot: bump io.dropwizard.metrics:metrics-core from 3.1.2 to 4.2…
dependabot[bot] Aug 1, 2023
ac57b48
dependabot: bump org.gradle.test-retry from 1.5.2 to 1.5.4 (#3072)
dependabot[bot] Aug 1, 2023
634e3af
Integrate geospatial ip2geo functionality with security plugin (#3051)
heemin32 Aug 1, 2023
eac670f
Update backport version for failure labels (#3063)
peternied Aug 1, 2023
bcbd2a0
audit logging tests, named routes
MaciejMierzwa Jul 31, 2023
5384272
Update CircuitBreakerService and LifecycleComponent after core refact…
cwperks Aug 1, 2023
cbb01e2
Merge branch 'main' into authorize-rest-requests_audit_log_test
MaciejMierzwa Aug 2, 2023
3d78135
Fix import for TransportAddress after core refactor #9073 (#3091)
willyborankin Aug 3, 2023
527495d
Add release notes for 1.3.12.0 (#3095)
cwperks Aug 4, 2023
527a289
Merge branch 'main' into authorize-rest-requests_audit_log_test
MaciejMierzwa Aug 4, 2023
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
4 changes: 2 additions & 2 deletions .github/actions/create-bwc-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runs:
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: assemble -Dbuild.snapshot=false
arguments: assemble
build-root-directory: ${{ inputs.plugin-branch }}

- id: get-opensearch-version
Expand All @@ -46,5 +46,5 @@ runs:
- name: Copy current distro into the expected folder
run: |
mkdir -p ./bwc-test/src/test/resources/${{ steps.get-opensearch-version.outputs.version }}
cp ${{ inputs.plugin-branch }}/build/distributions/opensearch-security-${{ steps.get-opensearch-version.outputs.version }}.zip ./bwc-test/src/test/resources/${{ steps.get-opensearch-version.outputs.version }}
cp ${{ inputs.plugin-branch }}/build/distributions/opensearch-security-${{ steps.get-opensearch-version.outputs.version }}-SNAPSHOT.zip ./bwc-test/src/test/resources/${{ steps.get-opensearch-version.outputs.version }}
shell: bash
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "dependabot:"
4 changes: 3 additions & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
installation_id: 22958780

- name: Backport
uses: VachaShah/backport@v1.1.4
uses: VachaShah/backport@v2.2.0
with:
github_token: ${{ steps.github_app_token.outputs.token }}
branch_name: backport/backport-${{ github.event.number }}
head_template: backport/backport-<%= number %>-to-<%= base %>
failure_labels: backport-failed
51 changes: 51 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ So you want to contribute code to OpenSearch Security? Excellent! We're glad you
- [Running integration tests](#running-integration-tests)
- [Bulk test runs](#bulk-test-runs)
- [Checkstyle Violations](#checkstyle-violations)
- [Authorization in REST Layer](#authorization-in-rest-layer)
- [Submitting Changes](#submitting-changes)
- [Backports](#backports)

Expand Down Expand Up @@ -78,6 +79,51 @@ mv config/* $OPENSEARCH_HOME/config/opensearch-security/
rm -rf config/
```

### Installing demo extension users and roles

If you are working with an extension and want to set up demo users for the Hello-World extension, append following items to files inside `$OPENSEARCH_HOME/config/opensearch-security/`:
1. In **internal_users.yml**
```yaml
hw-user:
hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG"
reserved: true
description: "Demo user for ext-test"
```

2. In **roles.yml**
```yaml
extension_hw_greet:
reserved: true
cluster_permissions:
- 'hw:greet'

extension_hw_full:
reserved: true
cluster_permissions:
- 'hw:goodbye'
- 'hw:greet'
- 'hw:greet_with_adjective'
- 'hw:greet_with_name'

legacy_hw_greet_with_name:
reserved: true
cluster_permissions:
- 'cluster:admin/opensearch/hw/greet_with_name'
```

3. In **roles_mapping.yml**
```yaml
legacy_hw_greet_with_name:
reserved: true
users:
- "hw-user"

extension_hw_greet:
reserved: true
users:
- "hw-user"
```

To install the demo certificates and default configuration, answer `y` to the first two questions and `n` to the last one. The log should look like below:

```bash
Expand Down Expand Up @@ -188,6 +234,11 @@ Checkstyle enforces several rules within this codebase. Sometimes it will be nec
// CS-ENFORCE-ALL
```

## Authorization in REST Layer

See [REST_AUTHZ_FOR_PLUGINS](REST_AUTHZ_FOR_PLUGINS.md).


## Submitting Changes

See [CONTRIBUTING](CONTRIBUTING.md).
Expand Down
136 changes: 136 additions & 0 deletions REST_AUTHZ_FOR_PLUGINS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Authorization at REST Layer for plugins

This feature is introduced as an added layer of security on top of existing TransportLayer authorization framework. In order to leverage these feature some core changes need to be made at Route registration level. This document talks about how you can achieve this.

**NOTE:** This doesn't replace Transport Layer Authorization. Plugin developers may choose to skip creating transport actions for APIs that do not need interaction with the Transport Layer.

## Pre-requisites

The security plugin must be installed and operational in your OpenSearch cluster for this feature to work.

### How does NamedRoute authorization work?

Once the routes are defined as NamedRoute, they, along-with their handlers, will be registered the same way as Route objects. When a request comes in, `SecurityRestFilter.java` applies an authorization check which extracts information about the NamedRoute.
Next we get the unique name and actionNames associated with that route and evaluate these against existing `cluster_permissions` across all roles of the requesting user. If the authorization check succeeds, the request chain proceeds as normal. If it fails, a 401 response is returned to the user.

NOTE:
1. The action names defined in roles must exactly match the names of registered routes, or else, the request would be deemed unauthorized.
2. This check will not be implemented for plugins who do not use NamedRoutes.



### How to translate an existing Route to be a NamedRoute?

Here is a sample of an existing route converted to a named route:
Before:
```
public List<Route> routes() {
return ImmutableList.of(
new Route(GET, "/uri")
);
}
```
With new scheme:
```
public List<NamedRoute> routes() {
return ImmutableList.of(
new NamedRoute.Builder().method(GET).path("/uri").uniqueName("plugin:uri").actionNames(Set.of("cluster:admin/opensearch/plugin/uri")).build()
);
}
```

`actionNames()` are optional. They correspond to any current actions defined as permissions in roles.
Ensure that these name-to-route mappings are easily accessible to the cluster admins to allow granting access to these APIs.

### How does authorization in the REST Layer work?

We will continue on the above example of translating `/uri` from Route to NamedRoute.

Consider these roles are defined in the cluster:
```yaml
plugin_role:
reserved: true
cluster_permissions:
- 'plugin:uri'

plugin_role_legacy:
reserved: true
cluster_permissions:
- 'cluster:admin/opensearch/plugin/uri'
```

Successful authz scenarios for a user:
1. The user is mapped either to `plugin_role` OR `plugin_role_legacy`.
2. The user is mapped to both of these roles.
3. The user is mapped to `plugin_role` even if no `actionNames()` were registered for this route.

Unsuccessful authz scenarios for a user:
1. The user is not mapped any roles.
2. The user is mapped to a different role which doesn't grant the cluster permissions: `plugin:uri` OR `cluster:admin/opensearch/plugin/uri`/
3. The user is mapped to a role `plugin_role_other` which has a typo in action name, i.e.`plugin:uuri`.


### Sample API in Security Plugin

As part of this effort a new uri `GET /whoamiprotected` was introduced as a NamedRoute version of `GET /whoami`. Here is how you can test it:

#### roles.yml
```yaml
who_am_i_role:
reserved: true
cluster_permissions:
- 'security:whoamiprotected'

who_am_i_role_legacy:
reserved: true
cluster_permissions:
- 'cluster:admin/opendistro_security/whoamiprotected'

who_am_i_role_no_perm:
reserved: true
cluster_permissions:
- 'some_invalid_perm'

```

#### internal_users.yml
```yaml
who_am_i-user:
hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG" #admin
reserved: true
description: "Demo user for ext-test"

who_am_i_legacy-user:
hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG"
reserved: true
description: "Demo user for ext-test"

who_am_i_no_perm-user:
hash: "$2a$12$VcCDgh2NDk07JGN0rjGbM.Ad41qVR/YFJcgHp0UGns5JDymv..TOG"
reserved: true
description: "Demo user for ext-test"
```

#### roles_mapping.yml
```yaml
who_am_i_role:
reserved: true
users:
- "who_am_i-user"

who_am_i_role_legacy:
reserved: true
users:
- "who_am_i_legacy-user"

who_am_i_role_no_perm:
reserved: true
users:
- "who_am_i_no_perm-user"
```

Follow [DEVELOPER_GUIDE](DEVELOPER_GUIDE.md) to setup OpenSearch cluster and initialize security plugin. Once you have verified that security plugin is installed correctly and OpenSearch is running, execute following curl requests:
1. `curl -XGET https://who_am_i-user:admin@localhost:9200/_plugins/_security/whoami --insecure` should succeed.
2. `curl -XGET https://who_am_i_legacy-user:admin@localhost:9200/_plugins/_security/whoami --insecure` should succeed.
3. `curl -XGET https://who_am_i_no-perm-user:admin@localhost:9200/_plugins/_security/whoami --insecure` should fail.
4. `curl -XPOST ` to `/whoami` with all 3 users should succeed. This is because POST route is not a NamedRoute and hence no authorization check was made.
13 changes: 13 additions & 0 deletions TRIAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ While we are always happy to help the community, the best resource for implement

There you can find answers to many common questions as well as speak with implementation experts.

### What are the issue labels associated with triaging?

Yes, there are several labels that are used to identify the 'state' of issues filed in OpenSearch and the Security Plugin.

| Label | When applied | Meaning |
| ----- | ------------ | ------- |
| Untriaged | When issues are created or re-opened. | Issues labeled as 'Untriaged' require the attention of the repository maintainers and may need to be prioritized for quicker resolution. It's crucial to keep the count of 'Untriaged' labels low to ensure all potential security issues are addressed in a timely manner. See [SECURITY.md](https://github.com/opensearch-project/security/blob/main/SECURITY.md) for more details on handling these issues. |
| Triaged | During triage meetings. | Issues labeled as 'Triaged' have been reviewed and are deemed actionable. Opening a pull request for an issue with the 'Triaged' label has a higher likelihood of approval from the project maintainers, particularly in novel areas. |
| Neither Label | During triage meetings. | This category is for issues that lack sufficient details to formulate a potential solution. Until more details are provided, it's difficult to ascertain if a proposed solution would be acceptable. When dealing with an 'Untriaged' issue that falls into this category, the triage team should provide further insights so the issue can be appropriately closed or labeled as 'Triaged'. Issues in this state are reviewed during every triage meeting. |
| Help Wanted | Anytime. | Issues marked as 'Help Wanted' signal that they are actionable and not the current focus of the project maintainers. Community contributions are especially encouraged for these issues. |
| Good First Issue | Anytime. | Issues labeled as 'Good First Issue' are small in scope and can be resolved with a single pull request. These are recommended starting points for newcomers looking to make their first contributions. |


### What if my issue is critical to OpenSearch operations, do I have to wait for the weekly meeting for it to be addressed?

All new issues for the [security](https://github.com/opensearch-project/security/issues?q=is%3Aissue+is%3Aopen+label%3Auntriaged) repo and [security-dashboards](https://github.com/opensearch-project/security-dashboards-plugin/issues?q=is%3Aissue+is%3Aopen+-label%3Atriaged) repo are reviewed daily to check for critical issues which require immediate triaging. If an issue relates to a severe concern for OpenSearch operation, it will be triaged by a maintainer mid-week. You can still come to discuss an issue at the following meeting even if it has already been triaged during the week.
Expand Down
Loading