Skip to content

Commit 0fb5f35

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Add support for the "*" permission for a pgorole
The RBAC permission list for a pgorole became quite large, and with new endpoints and, in turn, new permissions being added, this was becoming unwieldly. Coupled with the new installation and distribution methods, this became fraught with peril that we may accidentally block out a feature from being used. This adds the new "*" permissions that allows a pgorole to access any API server resource. This also sets it to be the default rule in all of the installation methods. Issue: [ch6742]
1 parent ce64343 commit 0fb5f35

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

ansible/inventory

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pgo_admin_password=''
6161

6262
# PGO Admin Role & Permissions
6363
pgo_admin_role_name='pgoadmin'
64-
pgo_admin_perms='DeleteNamespace,CreateNamespace,UpdatePgorole,ShowPgorole,DeletePgorole,CreatePgorole,UpdatePgouser,ShowPgouser,DeletePgouser,CreatePgouser,Cat,Ls,ShowNamespace,CreateDump,RestoreDump,ScaleCluster,CreateSchedule,DeleteSchedule,ShowSchedule,DeletePgbouncer,CreatePgbouncer,Restore,RestorePgbasebackup,ShowSecrets,Reload,ShowConfig,Status,DfCluster,DeleteCluster,ShowCluster,CreateCluster,TestCluster,ShowBackup,DeleteBackup,CreateBackup,Label,Load,CreatePolicy,DeletePolicy,ShowPolicy,ApplyPolicy,ShowWorkflow,ShowPVC,CreateUpgrade,CreateUser,DeleteUser,UpdateUser,ShowUser,Version,CreateFailover,UpdateCluster,CreateBenchmark,ShowBenchmark,DeleteBenchmark,UpdateNamespace,Clone'
64+
pgo_admin_perms='*'
6565

6666
# Namespace where operator will be deployed
6767
# NOTE: Ansible will create namespaces that don't exist

ansible/roles/pgo-operator/templates/pgorole-pgoadmin.yaml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
data:
3-
permissions: {{ pgo_admin_perms | b64encode }}
3+
permissions: "{{ pgo_admin_perms | b64encode }}"
44
rolename: {{ pgo_admin_role_name | b64encode }}
55
kind: Secret
66
metadata:
@@ -12,4 +12,3 @@ metadata:
1212
name: pgorole-{{ pgo_admin_role_name }}
1313
namespace: {{ pgo_operator_namespace }}
1414
type: Opaque
15-

apiserver/root.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,16 @@ func BasicAuthzCheck(username, perm string) bool {
267267
return false
268268
}
269269

270-
permsString := string(rolesecret.Data["permissions"])
270+
permsString := strings.TrimSpace(string(rolesecret.Data["permissions"]))
271+
272+
// first a special case. If this is a solitary "*" indicating that this
273+
// encompasses every permission, then we can exit here as true
274+
if permsString == "*" {
275+
return true
276+
}
277+
278+
// otherwise, blow up the permission string and see if the user has explicit
279+
// permission (i.e. is authorized) to access this resource
271280
perms := strings.Split(permsString, ",")
272281

273282
for _, p := range perms {

deploy/install-bootstrap-creds.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2020
export PGOADMIN_USERNAME=pgoadmin
2121
export PGOADMIN_PASSWORD=examplepassword
2222
export PGOADMIN_ROLENAME=pgoadmin
23-
export PGOADMIN_PERMS="DeleteNamespace,CreateNamespace,UpdatePgorole,ShowPgorole,DeletePgorole,CreatePgorole,UpdatePgouser,ShowPgouser,DeletePgouser,CreatePgouser,Cat,Ls,ShowNamespace,CreateDump,RestoreDump,ScaleCluster,CreateSchedule,DeleteSchedule,ShowSchedule,DeletePgbouncer,CreatePgbouncer,Restore,RestorePgbasebackup,ShowSecrets,Reload,ShowConfig,Status,DfCluster,DeleteCluster,ShowCluster,CreateCluster,TestCluster,ShowBackup,DeleteBackup,CreateBackup,Label,Load,CreatePolicy,DeletePolicy,ShowPolicy,ApplyPolicy,ShowWorkflow,ShowPVC,CreateUpgrade,CreateUser,DeleteUser,UpdateUser,ShowUser,Version,CreateFailover,UpdateCluster,CreateBenchmark,ShowBenchmark,DeleteBenchmark,UpdateNamespace,Clone"
23+
export PGOADMIN_PERMS="*"
2424

2525
# see if the bootstrap pgorole Secret exists or not, deleting it if found
2626
$PGO_CMD get secret pgorole-$PGOADMIN_ROLENAME -n $PGO_OPERATOR_NAMESPACE 2> /dev/null > /dev/null

deploy/pgorole-pgoadmin.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
stringData:
3-
permissions: $PGOADMIN_PERMS
3+
permissions: "$PGOADMIN_PERMS"
44
rolename: $PGOADMIN_ROLENAME
55
kind: Secret
66
metadata:
@@ -12,4 +12,3 @@ metadata:
1212
name: pgorole-$PGOADMIN_ROLENAME
1313
namespace: $PGO_OPERATOR_NAMESPACE
1414
type: Opaque
15-

hugo/content/Installation/install-with-ansible/prerequisites.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ sets of variables cannot be used at the same time.
203203
| `pgo_add_os_ca_store` | false | | When true, includes system default certificate authorities |
204204
| `pgo_admin_username` | admin | **Required** | Configures the pgo administrator username. |
205205
| `pgo_admin_password` | | **Required** | Configures the pgo administrator password. |
206-
| `pgo_admin_perms` | DeleteNamespace,CreateNamespace,UpdatePgorole,ShowPgorole,DeletePgorole,CreatePgorole,UpdatePgouser,ShowPgouser,DeletePgouser,CreatePgouser,Cat,Ls,ShowNamespace,CreateDump,RestoreDump,ScaleCluster,CreateSchedule,DeleteSchedule,ShowSchedule,DeletePgbouncer,CreatePgbouncer,Restore,RestorePgbasebackup,ShowSecrets,Reload,ShowConfig,Status,DfCluster,DeleteCluster,ShowCluster,CreateCluster,TestCluster,ShowBackup,DeleteBackup,CreateBackup,Label,Load,CreatePolicy,DeletePolicy,ShowPolicy,ApplyPolicy,ShowWorkflow,ShowPVC,CreateUpgrade,CreateUser,DeleteUser,UpdateUser,ShowUser,Version,CreateFailover,UpdateCluster,CreateBenchmark,ShowBenchmark,DeleteBenchmark,UpdateNamespace,Clone | **Required** | Sets the access control rules provided by the PostgreSQL Operator RBAC resources for the PostgreSQL Operator administrative account that is created by this installer. |
206+
| `pgo_admin_perms` | `*` | **Required** | Sets the access control rules provided by the PostgreSQL Operator RBAC resources for the PostgreSQL Operator administrative account that is created by this installer. Defaults to allowing all of the permissions, which is represented with the `*` |
207207
| `pgo_admin_role_name` | pgoadmin | **Required** | Sets the name of the PostgreSQL Operator role that is utilized for administrative operations performed by the PostgreSQL Operator. |
208208
| `pgo_apiserver_port` | 8443 | | Set to configure the port used by the Crunchy PostgreSQL Operator apiserver. |
209209
| `pgo_client_install` | true | | Configures the playbooks to install the `pgo` client if set to true. |
@@ -219,7 +219,7 @@ sets of variables cannot be used at the same time.
219219
| `pgo_tls_no_verify` | false | | Set to configure Operator to verify TLS certificates. |
220220
| `pgo_client_container_install` | false | | Installs the pgo-client deployment along with ansible isnstall |
221221
| `pgo_apiserver_url` | `https://postgres-operator` | | Sets the `pgo_apiserver_url` in the pgo-client deployment |
222-
| `pgo_client_cert_secret` | `pgo.tls` | | Sets the secret that the pgo-client will use when connecting to the operator. Secret should hold the TLS certs |
222+
| `pgo_client_cert_secret` | `pgo.tls` | | Sets the secret that the pgo-client will use when connecting to the operator. Secret should hold the TLS certs |
223223
| `primary_storage` | storageos | **Required** | Set to configure which storage definition to use when creating volumes used by PostgreSQL primaries on all newly created clusters. |
224224
| `prometheus_install` | true | | Set to true to install Crunchy Prometheus timeseries database. |
225225
| `prometheus_storage_access_mode` | | | Set to the access mode used by the configured storage class for Prometheus persistent volumes. |

hugo/content/Security/configure-postgres-operator-rbac.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ If the user tries to access a namespace that they are not configured for within
4343
Error: user [pgouser1] is not allowed access to namespace [pgouser2]
4444

4545

46+
If you wish to add all avaiable permissions to a *pgorole*, you can specify it by using a single `*` in your configuration. Note that if you are editing your YAML file directly, you will need to ensure to write it as `"*"` to ensure it is recognized as a string.
47+
4648
The following list shows the current complete list of possible pgo permissions that you can specify within the *pgorole* file when creating roles:
4749

4850
|Permission|Description |
@@ -93,7 +95,7 @@ The following list shows the current complete list of possible pgo permissions t
9395

9496
If the user is unauthorized for a pgo command, the user will get back this response:
9597

96-
Error: Authentication Failed: 401
98+
Error: Authentication Failed: 403
9799

98100
## Making Security Changes
99101

installers/gcp-marketplace/inventory.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pgo_admin_password='${OPERATOR_ADMIN_PASSWORD}'
99

1010
# PGO Admin Role & Permissions
1111
pgo_admin_role_name='pgoadmin'
12-
pgo_admin_perms='DeleteNamespace,CreateNamespace,UpdatePgorole,ShowPgorole,DeletePgorole,CreatePgorole,UpdatePgouser,ShowPgouser,DeletePgouser,CreatePgouser,Cat,Ls,ShowNamespace,CreateDump,RestoreDump,ScaleCluster,CreateSchedule,DeleteSchedule,ShowSchedule,DeletePgbouncer,CreatePgbouncer,Restore,RestorePgbasebackup,ShowSecrets,Reload,ShowConfig,Status,DfCluster,DeleteCluster,ShowCluster,CreateCluster,TestCluster,ShowBackup,DeleteBackup,CreateBackup,Label,Load,CreatePolicy,DeletePolicy,ShowPolicy,ApplyPolicy,ShowWorkflow,ShowPVC,CreateUpgrade,CreateUser,DeleteUser,UpdateUser,ShowUser,Version,CreateFailover,UpdateCluster,CreateBenchmark,ShowBenchmark,DeleteBenchmark,UpdateNamespace,Clone'
12+
pgo_admin_perms='*'
1313

1414
pgo_installation_name='${OPERATOR_NAME}'
1515
pgo_operator_namespace='${OPERATOR_NAMESPACE}'

0 commit comments

Comments
 (0)