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

feat: disable ALTER SYSTEM by default #3545

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions api/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,8 +1181,7 @@ type PostgresConfiguration struct {
// If this parameter is true, the user will be able to invoke `ALTER SYSTEM`
// on this CloudNativePG Cluster.
// This should only be used for debugging and troubleshooting.
// Defaults to true.
// +kubebuilder:default:=true
// Defaults to false.
// +optional
EnableAlterSystem bool `json:"enableAlterSystem,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/postgresql.cnpg.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2721,11 +2721,10 @@ spec:
description: Configuration of the PostgreSQL server
properties:
enableAlterSystem:
default: true
description: If this parameter is true, the user will be able
to invoke `ALTER SYSTEM` on this CloudNativePG Cluster. This
should only be used for debugging and troubleshooting. Defaults
to true.
to false.
type: boolean
ldap:
description: Options to specify LDAP configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/src/cloudnative-pg.v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -3560,7 +3560,7 @@ big enough to simulate an infinite timeout</p>
<p>If this parameter is true, the user will be able to invoke <code>ALTER SYSTEM</code>
on this CloudNativePG Cluster.
This should only be used for debugging and troubleshooting.
Defaults to true.</p>
Defaults to false.</p>
</td>
</tr>
</tbody>
Expand Down
24 changes: 15 additions & 9 deletions docs/src/installation_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,16 @@ only the operator itself.
from 1.20.x to 1.22, make sure you go through the release notes
and upgrade instructions for 1.21 and 1.22.

CloudNativePG keeps following the *security-by-default* approach and, after
disabling `postgres` superuser access via the network in all new clusters, it
now disables by default the usage of the `ALTER SYSTEM` command.
CloudNativePG continues to adhere to the security-by-default approach. As of
version 1.22, the usage of the `ALTER SYSTEM` command is now disabled by
default.

The reason behind this choice is to ensure that, by default, changes to the
PostgreSQL configuration in a database cluster controlled by CloudNativePG are
allowed only through the Kubernetes API.

At the same time, we are providing an option to enable `ALTER SYSTEM` if you
need to use it, even temporarily.

If you want to retain the existing behavior, you need to explicitly enable it
by setting `.spec.postgresql.enableAlterSystem` to `true`, as in the following
Expand All @@ -265,12 +272,11 @@ excerpt:
...
```

The reason behind this choice is to ensure that, by default, changes to the
PostgreSQL configuration in a database cluster controlled by CloudNativePG are
allowed only through the Kubernetes API.

At the same time, we are providing an option to enable `ALTER SYSTEM` if you
need to use it, even temporarily.
!!! Important
You can execute this operation immediately following your upgrade to
version 1.22.0. Alternatively, you have the option to first upgrade to either
version 1.21.2 or 1.20.5 and then explicitly set it to true, as demonstrated in
the example above.

### Upgrading to 1.21 from a previous minor version

Expand Down
Loading