-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[ysql] Default ysql_hba settings for --use_client_to_server_encryption=true are too restrictive #7153
Comments
… server encryption Summary: 1. Add 'ysql_hba_conf_csv' lines at the beginning of ysql_hba.conf: Specifically add the custom configuration set using the 'ysql_hba_conf_csv' before the lines auto-generated by the ysql_enable_auth (enable authentication) and the use_client_to_server_encryption (enable TLS encryption) flags. This way users can customize the auto-generated configurations because YSQL always picks the first matching HBA rule to verify authentication. Note that if the custom user-defined rules only apply to some hosts, users, databases, then the we would still get to the auto-generated rules below for the non-matching hosts, users, or databases. To fully disable those, one can use the 'reject' auth method. For instance, to enable TLS with cert authentication, but only for some particular database, user and host, one can use the following ysql_hba_conf_csv setting: ``` hostssl mydb myuser myhost cert,hostssl all all all reject``` The first rule sets the intended config, the latter one "disables" the auto-generated rules. 2. Default ysql_hba settings for '--use_client_to_server_encryption=true' were too restrictive: The current settings depending on whether auth (ysql_enable_auth) and/or TLS (use_client_to_server_encryption) are enabled TLS disabled -- auth disabled -> hba setting 'host all all all trust' - no auth, trust all -- auth enabled -> hba setting 'host all all all md5' - password based auth TLS enabled -- auth disabled -> hba setting 'hostssl all all all trust' - require ssl but trust (previously was 'cert', so client cert was required) -- auth enabled -> hba setting 'hostssl all all all md5' - require ssl and password (previously it was 'md5 clientcert=1', so both password and client cert were needed) To obtain the old behavior with the new semantics, one should use the `ysql_hba_conf_csv` (together with use_client_to_server_encryption) and set it to the following configuration: ``` hostssl all all all md5 clientcert=1 ``` Test Plan: Jenkins, TestPgConfiguration, TestPgAuthorization, added TestPgEncryption Reviewers: dmitry, sanketh Reviewed By: sanketh Subscribers: jdoty, tramer, amey, yql Differential Revision: https://phabricator.dev.yugabyte.com/D10579
Fixed by 8ef3197. SummaryThere are three main configuration flags related to TLS:
The current default (auto-generated) configuration depends on whether auth ( The four cases are shown in the table below:
Note: Previously the TLS enabled case used the more strict Additionally, For instance to use TLS with both md5 and cert authentication one can set the
Note: Implementation-wise, the Therefore, If the custom user-defined rules only apply to some connection-types (e.g. For instance, to enable TLS with
ExamplesPrerequisitesDownload and configure some sample certificates:
Note: 1. Cluster with TLS enabled but no authenticationWill require the client to use client-to-server encryption to connect. Create
ConnectSSL must be enabled in the client to connect.
The default ysqlsh option is So, in this case, a plain
(Therefore, we omit the 2. Cluster with TLS enabled and (password) authenticationWill require the client to use client-to-server encryption and authenticate with a password to connect. Create
ConnectSame as case 1. above but the password will now be required (see second line below):
The other cases (e.g 3. Cluster with custom configuration (TLS and authentication via cert)Will require the client to use client-to-server encryption and authenticate with the appropriate certificate to connect. Note: This was the previous default for TLS enabled without auth (case 1. above). So this example also shows the appropriate Create
ConnectNow a certificate will be required to connect (but no password).
4. Cluster with custom configuration (TLS and auth with both md5 and cert)Will require the client to use client-to-server encryption and authenticate both with the appropriate certificate and the password to connect. Note: This was the previous default for TLS enabled with auth (case 2. above). So this example also shows the appropriate Create
ConnectWill require the certificate to be set, and also ask for a password (see second line in the second example below)
|
…ts for client to server encryption Summary: 1. Add 'ysql_hba_conf_csv' lines at the beginning of ysql_hba.conf: Specifically add the custom configuration set using the 'ysql_hba_conf_csv' before the lines auto-generated by the ysql_enable_auth (enable authentication) and the use_client_to_server_encryption (enable TLS encryption) flags. This way users can customize the auto-generated configurations because YSQL always picks the first matching HBA rule to verify authentication. Note that if the custom user-defined rules only apply to some hosts, users, databases, then the we would still get to the auto-generated rules below for the non-matching hosts, users, or databases. To fully disable those, one can use the 'reject' auth method. For instance, to enable TLS with cert authentication, but only for some particular database, user and host, one can use the following ysql_hba_conf_csv setting: ``` hostssl mydb myuser myhost cert,hostssl all all all reject``` The first rule sets the intended config, the latter one "disables" the auto-generated rules. 2. Default ysql_hba settings for '--use_client_to_server_encryption=true' were too restrictive: The current settings depending on whether auth (ysql_enable_auth) and/or TLS (use_client_to_server_encryption) are enabled TLS disabled -- auth disabled -> hba setting 'host all all all trust' - no auth, trust all -- auth enabled -> hba setting 'host all all all md5' - password based auth TLS enabled -- auth disabled -> hba setting 'hostssl all all all trust' - require ssl but trust (previously was 'cert', so client cert was required) -- auth enabled -> hba setting 'hostssl all all all md5' - require ssl and password (previously it was 'md5 clientcert=1', so both password and client cert were needed) To obtain the old behavior with the new semantics, one should use the `ysql_hba_conf_csv` (together with use_client_to_server_encryption) and set it to the following configuration: ``` hostssl all all all md5 clientcert=1 ``` Original commit: D10579 / 8ef3197 Test Plan: Jenkins, TestPgConfiguration, TestPgAuthorization, added TestPgEncryption Reviewers: dmitry, sanketh Subscribers: yql, amey, tramer, jdoty Differential Revision: https://phabricator.dev.yugabyte.com/D10654
…s for client to server encryption Summary: 1. Add 'ysql_hba_conf_csv' lines at the beginning of ysql_hba.conf: Specifically add the custom configuration set using the 'ysql_hba_conf_csv' before the lines auto-generated by the ysql_enable_auth (enable authentication) and the use_client_to_server_encryption (enable TLS encryption) flags. This way users can customize the auto-generated configurations because YSQL always picks the first matching HBA rule to verify authentication. Note that if the custom user-defined rules only apply to some hosts, users, databases, then the we would still get to the auto-generated rules below for the non-matching hosts, users, or databases. To fully disable those, one can use the 'reject' auth method. For instance, to enable TLS with cert authentication, but only for some particular database, user and host, one can use the following ysql_hba_conf_csv setting: ``` hostssl mydb myuser myhost cert,hostssl all all all reject``` The first rule sets the intended config, the latter one "disables" the auto-generated rules. 2. Default ysql_hba settings for '--use_client_to_server_encryption=true' were too restrictive: The current settings depending on whether auth (ysql_enable_auth) and/or TLS (use_client_to_server_encryption) are enabled TLS disabled -- auth disabled -> hba setting 'host all all all trust' - no auth, trust all -- auth enabled -> hba setting 'host all all all md5' - password based auth TLS enabled -- auth disabled -> hba setting 'hostssl all all all trust' - require ssl but trust (previously was 'cert', so client cert was required) -- auth enabled -> hba setting 'hostssl all all all md5' - require ssl and password (previously it was 'md5 clientcert=1', so both password and client cert were needed) To obtain the old behavior with the new semantics, one should use the `ysql_hba_conf_csv` (together with use_client_to_server_encryption) and set it to the following configuration: ``` hostssl all all all md5 clientcert=1 ``` Original commit: D10579 / 8ef3197 Test Plan: Jenkins: rebase: 2.4 TestPgConfiguration, TestPgAuthorization, added TestPgEncryption Reviewers: dmitry, sanketh, mihnea Reviewed By: mihnea Subscribers: yql, amey, tramer, jdoty Differential Revision: https://phabricator.dev.yugabyte.com/D10654
…ts for client to server encryption Summary: 1. Add 'ysql_hba_conf_csv' lines at the beginning of ysql_hba.conf: Specifically add the custom configuration set using the 'ysql_hba_conf_csv' before the lines auto-generated by the ysql_enable_auth (enable authentication) and the use_client_to_server_encryption (enable TLS encryption) flags. This way users can customize the auto-generated configurations because YSQL always picks the first matching HBA rule to verify authentication. Note that if the custom user-defined rules only apply to some hosts, users, databases, then the we would still get to the auto-generated rules below for the non-matching hosts, users, or databases. To fully disable those, one can use the 'reject' auth method. For instance, to enable TLS with cert authentication, but only for some particular database, user and host, one can use the following ysql_hba_conf_csv setting: ``` hostssl mydb myuser myhost cert,hostssl all all all reject``` The first rule sets the intended config, the latter one "disables" the auto-generated rules. 2. Default ysql_hba settings for '--use_client_to_server_encryption=true' were too restrictive: The current settings depending on whether auth (ysql_enable_auth) and/or TLS (use_client_to_server_encryption) are enabled TLS disabled -- auth disabled -> hba setting 'host all all all trust' - no auth, trust all -- auth enabled -> hba setting 'host all all all md5' - password based auth TLS enabled -- auth disabled -> hba setting 'hostssl all all all trust' - require ssl but trust (previously was 'cert', so client cert was required) -- auth enabled -> hba setting 'hostssl all all all md5' - require ssl and password (previously it was 'md5 clientcert=1', so both password and client cert were needed) To obtain the old behavior with the new semantics, one should use the `ysql_hba_conf_csv` (together with use_client_to_server_encryption) and set it to the following configuration: ``` hostssl all all all md5 clientcert=1 ``` Test Plan: Jenkins, TestPgConfiguration, TestPgAuthorization, added TestPgEncryption Reviewers: dmitry, sanketh Reviewed By: sanketh Subscribers: jdoty, tramer, amey, yql Differential Revision: https://phabricator.dev.yugabyte.com/D10579
Here's how the hba file for SQL clients work for different flag settings related to TLS and auth
When TLS is enabled the settings are too restrictive because they always require a client cert and are inconsistent with the earlier case.
The text was updated successfully, but these errors were encountered: