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

[FEATURE] New reserved roles are not sourced to security index on an upgrade #2316

Closed
cwperks opened this issue Dec 9, 2022 · 11 comments
Closed
Assignees
Labels
enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@cwperks
Copy link
Member

cwperks commented Dec 9, 2022

Is your feature request related to a problem?

New reserved roles are often added between releases when a new plug-in is released and associated roles are created to provision access to features of the new plugin. Reserved roles are added to the security repo roles.yml like is done in this PR: #2192 which introduces 3 new reserved roles between 2.3.0 and 2.4.0.

When starting up a cluster with the upgraded version of OpenSearch I receive the following line:

Index .opendistro_security already contains doc with id roles, skipping update

indicating that the new reserved roles in roles.yml will need to be manually added either via the API by an admin or via securityadmin tool connecting via clientcert as a super admin.

This becomes additionally complicated when users of OpenSearch add custom roles or modify the security index in any way via the OSD UI or API as it is destructive to run securityadmin.sh because it can delete custom configuration. In order to get around this I have:

  1. Ran a backup of the security index using security admin: https://opensearch.org/docs/latest/security-plugin/configuration/security-admin/#a-word-of-caution
  2. Reconcile the exported roles.yml with new reserved roles in the repo's roles.yml: https://github.com/opensearch-project/security/blob/main/config/roles.yml
  3. Run securityadmin.sh with the coalesced exported roles.yml with custom roles and the repo's roles.yml of the corresponding version of opensearch

This is not an idea process and there can be a better solution to source new reserved roles during an upgrade

@cwperks cwperks added enhancement New feature or request untriaged Require the attention of the repository maintainers and may need to be prioritized triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable. and removed untriaged Require the attention of the repository maintainers and may need to be prioritized labels Dec 9, 2022
@peternied
Copy link
Member

@opensearch-project/security-analytics This scenario might be impacting y'all, it might be worthwhile to invest in this scenario. Here is where I believe there is a lot of overlap, after upgrading a cluster that does not have the new roles needed for the security-analytics plugin when it is 'upgraded-in' on at a later time.

@cwperks
Copy link
Member Author

cwperks commented Dec 12, 2022

[Triage] In the short-term this can be a documentation fix.

@peternied to follow-up on this issue.

@eirsep
Copy link
Member

eirsep commented Feb 16, 2023

One possible solution:
Have 2 security config indices - one for pre-defined roles (internal to Opensearch and its plugins) and one for execlusively for user defined roles
On every node restart/bootup (or a new admin API invocation), we should reload roles/permissions into the pre-defined roles index from the yml file and leave the user security roles as is.

This would remove some of the static-ness from our design and solve the problem for upgrading domains getting the latest roles and permissions from yml file without user action/documentation.

@peterzhuamazon
Copy link
Member

This is observed on a cluster where the cluster was upgrade from 1.3 to 2.3 and missing CCR perms and roles. This does not resolve after redeploy.

@peternied
Copy link
Member

This is observed on a cluster where the cluster was upgrade from 1.3 to 2.3 and missing CCR perms and roles. This does not resolve after redeploy.

This is the expected behavior, the security plugin does not alter the security configuration on established clusters. Cluster administrators can add this functionality via the security admin tool https://opensearch.org/docs/latest/security/configuration/security-admin

This feature request is about adding this functionality which some administrators might be comfortable with, whereas others might not want this behavior. Its a complex scenario based on the expectations of the administrator, we would be open for pull requests around this space.

@peterzhuamazon
Copy link
Member

peterzhuamazon commented May 2, 2023

This is observed on a cluster where the cluster was upgrade from 1.3 to 2.3 and missing CCR perms and roles. This does not resolve after redeploy.

This is the expected behavior, the security plugin does not alter the security configuration on established clusters. Cluster administrators can add this functionality via the security admin tool https://opensearch.org/docs/latest/security/configuration/security-admin

This feature request is about adding this functionality which some administrators might be comfortable with, whereas others might not want this behavior. Its a complex scenario based on the expectations of the administrator, we would be open for pull requests around this space.

Got it, it would be nice if it can prompt a windows to let me know new roles in 2.3 version after upgrade. This would be very handy and easy for the users.

Without this, I was fairly confused for half a day trying to figure out is my cluster have enough permission to run ccr, with multiple b/g and upgrade to latest version, without using the all_access role.

Thanks.

@peternied
Copy link
Member

@peterzhuamazon Roger that - must have been frustrating. Good idea about the warning.

@peternied peternied self-assigned this Feb 23, 2024
@peternied
Copy link
Member

Proposal - Check/Upgrade reserved roles from config

OpenSearch's security defaults are controlled by the ./config/.* files, including roles. This file contains many reserved roles that are updated by plugins for in OpenSearch distribution. By checking the reserved roles against the roles of the cluster we could detect that an update to the reserved roles might be needed and also apply an update resync these roles.

Updated eligible check on startup

On the security plugin start - for only the master node, read the config/roles.yml file into memory, compare that all roles on disk exist, if not then suggest an upgrade. Then check that all roles have the same permissions, if they do not then suggest an upgrade. Do this as a single warning message that includes the REST API to use to perform this upgrade - [WARN] Reserved roles do not match the defaults from ./config/roles.yml. Resync these roles by calling "POST /_plugins/_security/api/_reserved/_upgrade_apply".

Upgrade eligible check via API

Create an API "GET /_plugins/_security/api/_reserved/_upgrade_check" that can be used by tools to determine the upgrade state with the following responses.

200 OK
{
   "canUpgrade": true
   "roles": {
       "missingRoles": [
            // Full role definition
           "{ROLE-NAME}: {
              "cluster_permissions": ...
           }
       ],
       "updatedRoles": [
            ...
       ]
    }
}

Upgrade action via API

Create an API "POST /_plugins/_security/api/_reserved/_upgrade_apply" that triggers an upgrade, overrides all permissions on reserved roles and replaces them with what is found in the config/roles.yml file. Internally this will be handled the same as a PATCH request to the roles API

200 OK
{
  "status": "OK",
  "message": "Reserved roles '<role>,...' added, '<role>,...' updated."
}

Security admin tool

Add additional options to the security admin tool to include options to check this API and perform the upgrade.

@cwperks
Copy link
Member Author

cwperks commented Feb 27, 2024

@peternied This approach looks good to me. I think it makes sense to create an API where you can check to see if your current security config has the latest version of all reserved rolls.

I know there is no current mapping between role -> plugin, but if its possible, it would also be interesting to take into account whether a specific plugin is installed and that the roles associated with the plugins exist in the security index.

@peternied
Copy link
Member

FYI @cwperks draft PR willyborankin#1

DarshitChanpura pushed a commit that referenced this issue Mar 20, 2024
…4102)

### Description
This adds a new API that allows for checking and updating configurations
from the default configurations on disk. Initial feature supports only
Roles.

#### Response when no upgrade is available
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : false
}
```
#### Response when a new role is available
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : true,
  "upgradeActions" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ]
    }
  }
}
```
#### Response when a new role + existing role were updated
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : true,
  "upgradeActions" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ],
      "modify" : [ "flow_framework_read_access" ]
    }
  }
}
```
#### Perform an upgrade
```
POST _plugins/_security/api/_upgrade_perform
200 {
  "status" : "OK",
  "upgrades" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ],
      "modify" : [ "flow_framework_read_access" ]
    }
  }
}
```

#### Perform an upgrade when unneeded
```
POST _plugins/_security/api/_upgrade_perform
400 {
   "status": "BAD_REQUEST",
   "message": "Unable to upgrade, no differences found in 'roles' config"
}
```

### Issues Resolved
- #2316

### Testing
New unit test and integration test cases

### Check List
- [X] New functionality includes testing
- [ ] New functionality has been documented
- [X] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Peter Nied <[email protected]>
Signed-off-by: Andrey Pleskach <[email protected]>
Signed-off-by: Peter Nied <[email protected]>
willyborankin pushed a commit to willyborankin/security that referenced this issue Apr 15, 2024
…pensearch-project#4102)

This adds a new API that allows for checking and updating configurations
from the default configurations on disk. Initial feature supports only
Roles.

```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : false
}
```
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : true,
  "upgradeActions" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ]
    }
  }
}
```
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : true,
  "upgradeActions" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ],
      "modify" : [ "flow_framework_read_access" ]
    }
  }
}
```
```
POST _plugins/_security/api/_upgrade_perform
200 {
  "status" : "OK",
  "upgrades" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ],
      "modify" : [ "flow_framework_read_access" ]
    }
  }
}
```

```
POST _plugins/_security/api/_upgrade_perform
400 {
   "status": "BAD_REQUEST",
   "message": "Unable to upgrade, no differences found in 'roles' config"
}
```

- opensearch-project#2316

New unit test and integration test cases

- [X] New functionality includes testing
- [ ] New functionality has been documented
- [X] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Peter Nied <[email protected]>
Signed-off-by: Andrey Pleskach <[email protected]>
Signed-off-by: Peter Nied <[email protected]>
(cherry picked from commit fa877ba)
dlin2028 pushed a commit to dlin2028/security that referenced this issue May 1, 2024
…pensearch-project#4102)

### Description
This adds a new API that allows for checking and updating configurations
from the default configurations on disk. Initial feature supports only
Roles.

#### Response when no upgrade is available
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : false
}
```
#### Response when a new role is available
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : true,
  "upgradeActions" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ]
    }
  }
}
```
#### Response when a new role + existing role were updated
```
GET _plugins/_security/api/_upgrade_check
200 {
  "status": "ok",
  "upgradeAvailable" : true,
  "upgradeActions" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ],
      "modify" : [ "flow_framework_read_access" ]
    }
  }
}
```
#### Perform an upgrade
```
POST _plugins/_security/api/_upgrade_perform
200 {
  "status" : "OK",
  "upgrades" : {
    "roles" : {
      "add" : [ "flow_framework_full_access" ],
      "modify" : [ "flow_framework_read_access" ]
    }
  }
}
```

#### Perform an upgrade when unneeded
```
POST _plugins/_security/api/_upgrade_perform
400 {
   "status": "BAD_REQUEST",
   "message": "Unable to upgrade, no differences found in 'roles' config"
}
```

### Issues Resolved
- opensearch-project#2316

### Testing
New unit test and integration test cases

### Check List
- [X] New functionality includes testing
- [ ] New functionality has been documented
- [X] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Peter Nied <[email protected]>
Signed-off-by: Andrey Pleskach <[email protected]>
Signed-off-by: Peter Nied <[email protected]>
@peternied
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Projects
None yet
Development

No branches or pull requests

4 participants