User authentication rules
User authentication rules determine which users from which addresses are allowed to connect to a cluster, as well as which databases they can access.
You can:
Warning
The rule priority matches the order of rows: rules are read from top to bottom, and the first relevant rule applies. If authentication based on the first suitable rule fails, other rules do not apply.
Getting a list of rules
- Open the folder dashboard
. - Navigate to Yandex MPP Analytics for PostgreSQL.
- Click the cluster name and open the
User authentication tab.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the command for getting a list of rules:
yc managed-greenplum hba-rules list --help -
Get a list of rules:
yc managed-greenplum hba-rules list --cluster-id <cluster_ID>You can get the cluster ID with the list of clusters in the folder.
Result:
+----------+-----------------+-----+-------+-------------------------------------------+-------------+ | PRIORITY | CONNECTION TYPE | DB | USER | ADDRESS | AUTH METHOD | +----------+-----------------+-----+-------+-------------------------------------------+-------------+ | 1 | HOST | db1 | user1 | rc1a-no8u9mlr********.mdb.yandexcloud.net | MD5 | +----------+-----------------+-----+-------+-------------------------------------------+-------------+
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the HBARule.List method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>/hbaRules'You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the HBARuleService.List method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/hba_rule_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.greenplum.v1.HBARuleService.ListYou can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
Adding a rule
-
Open the folder dashboard
. -
Navigate to Yandex MPP Analytics for PostgreSQL.
-
Click the cluster name and open the
User authentication tab. -
Click Edit rules.
-
Click
Add rule and specify its settings:- Type: Connection type.
- Database: Name of the database to connect to. You cannot specify system databases.
- User: Name of the database user or user group. You cannot specify system users.
- Address (CIDR/FQDN): Host FQDN or IP range in CIDR notation to connect to the database from.
- Method: Authentication method.
For more information about the parameters, see Authentication rule settings.
-
To add another rule, click
Add rule. -
Click Save.
Note
The default rule is added automatically at the end of the list; it allows authentication for all users in all databases and from all hosts using the md5 method (password-based authentication).
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the add rule command:
yc managed-greenplum hba-rules create --help -
Add the rule:
yc managed-greenplum hba-rules create <rule_priority> \ --cluster-id <cluster_ID> \ --conn-type <interconnect_type> \ --database <DB_name> \ --user <username> \ --address <address> \ --auth-method <authentication_method>Where:
conn-type: Interconnect type. The possible values arehost,hostssl, andhostnossl.address: Host FQDN or IP range in CIDR notation to connect to the database from.auth-method: Authentication method. It can be eithermd5orreject.
For more information, see Authentication rule settings.
You can get the cluster ID with the list of clusters in the folder.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the HBARule.Create method, e.g., via the following cURL
request:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>/hbaRules' \ --data '{ "hbaRule": { "priority": "<rule_priority>", "connectionType": "<interconnect_type>", "database": "<DB_name>", "user": "<username>", "address": "<address>", "authMethod": "<authentication_method>" } }'Where:
connectionType: Interconnect type. The possible values areHOST,HOSTSSL, andHOSTNOSSL.address: Host FQDN or IP range in CIDR notation to connect to the database from.authMethod: Authentication method. It can be eitherMD5orREJECT.
For more information, see Authentication rule settings.
You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the HBARuleService.Create method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/hba_rule_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "hba_rule": { "priority": "<rule_priority>", "connection_type": "<interconnect_type>", "database": "<DB_name>", "user": "<username>", "address": "<address>", "auth_method": "<authentication_method>" } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.greenplum.v1.HBARuleService.CreateWhere:
connection_type: Interconnect type. The possible values areHOST,HOSTSSL, andHOSTNOSSL.address: Host FQDN or IP range in CIDR notation to connect to the database from.auth_method: Authentication method. It can be eitherMD5orREJECT.
You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
Editing a rule
-
Open the folder dashboard
. -
Navigate to Yandex MPP Analytics for PostgreSQL.
-
Click the cluster name and open the
User authentication tab. -
Click Edit rules and update the rule settings:
- Type: Connection type.
- Database: Name of the database to connect to. You cannot specify system databases.
- User: Name of the database user or user group. You cannot specify system users.
- Address (CIDR/FQDN): Host FQDN or IP range in CIDR notation to connect to the database from.
- Method: Authentication method.
For more information about the parameters, see Authentication rule settings.
-
Click Save.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the update rule command:
yc managed-greenplum hba-rules update --help -
Update the rule:
yc managed-greenplum hba-rules update <rule_priority> \ --cluster-id <cluster_ID> \ --conn-type <interconnect_type> \ --database <DB_name> \ --user <username> \ --address <address> \ --auth-method <authentication_method>Where:
conn-type: Interconnect type. The possible values arehost,hostssl, andhostnossl.address: Host FQDN or IP range in CIDR notation to connect to the database from.auth-method: Authentication method. It can be eithermd5orreject.
For more information, see Authentication rule settings.
You can get the cluster ID with the list of clusters in the folder.
You can find out the rule priority by requesting a list of all rules in the cluster.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the HBARule.Update method, e.g., via the following cURL
request:curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>/hbaRules' \ --data '{ "hbaRule": { "priority": "<rule_priority>", "connectionType": "<interconnect_type>", "database": "<DB_name>", "user": "<username>", "address": "<address>", "authMethod": "<authentication_method>" } }'Where:
connectionType: Interconnect type. The possible values areHOST,HOSTSSL, andHOSTNOSSL.address: Host FQDN or IP range in CIDR notation to connect to the database from.authMethod: Authentication method. It can be eitherMD5orREJECT.
For more information, see Authentication rule settings.
You can get the cluster ID with the list of clusters in the folder.
You can find out the rule priority by requesting a list of all rules in the cluster.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the HBARuleService.Update method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/hba_rule_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "hba_rule": { "priority": "<rule_priority>", "connection_type": "<interconnect_type>", "database": "<DB_name>", "user": "<username>", "address": "<address>", "auth_method": "<authentication_method>" } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.greenplum.v1.HBARuleService.UpdateWhere:
connection_type: Interconnect type. The possible values areHOST,HOSTSSL, andHOSTNOSSL.address: Host FQDN or IP range in CIDR notation to connect to the database from.auth_method: Authentication method. It can be eitherMD5orREJECT.
You can get the cluster ID with the list of clusters in the folder.
You can find out the rule priority by requesting a list of all rules in the cluster.
-
View the server response to make sure your request was successful.
Change the rule priority
- Open the folder dashboard
. - Navigate to Yandex MPP Analytics for PostgreSQL.
- Click the cluster name and open the
User authentication tab. - Click Edit rules.
- Click
for your rule and move it up or down. - Click Save.
Deleting a rule
- Open the folder dashboard
. - Navigate to Yandex MPP Analytics for PostgreSQL.
- Click the cluster name and open the
User authentication tab. - Click Edit rules.
- Click
for your rule and select Delete. - Click Save.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the command for deleting a rule:
yc managed-greenplum hba-rules delete --help -
Delete the rule:
yc managed-greenplum hba-rules delete <rule_priority> \ --cluster-id <cluster_ID>
You can get the cluster ID with the list of clusters in the folder.
You can find out the rule priority by requesting a list of all rules in the cluster.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the HBARule.Delete method, e.g., via the following cURL
request:curl \ --request DELETE \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>/hbaRule/<rule_priority>'You can get the cluster ID with the list of clusters in the folder.
You can find out the rule priority by requesting a list of all rules in the cluster.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the HBARuleService.Delete method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/hba_rule_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "priority": "<rule_priority>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.greenplum.v1.HBARuleService.DeleteYou can get the cluster ID with the list of clusters in the folder.
You can find out the rule priority by requesting a list of all rules in the cluster.
-
View the server response to make sure your request was successful.