auth_config
YDB supports various user authentication methods. The configuration for authentication providers is specified in the auth_config section.
Configuring Local YDB User Authentication
For more information about the authentication of local YDB users, see Authenticating by username and password. To configure authentication by username and password, define the following parameters in the auth_config section:
|
Parameter |
Description |
|
use_login_provider |
Indicates whether to allow the authentication of local users with an authentication token that is obtained after entering a username and password. Default value: |
|
enable_login_authentication |
Indicates whether to allow adding local users to YDB databases and generating authentication tokens after a local user enters a username and password. Default value: |
|
domain_login_only |
Determines the scope of local user access rights in a YDB cluster. Valid values:
Default value: |
|
login_token_expire_time |
Specifies the expiration time of the authentication token created when a local user logs in to YDB. Default value: |
Configuring User Lockout
You can configure YDB to lock a user account out after a specified number of failed attempts to enter the correct password. To configure user lockout, define the account_lockout subsection inside the auth_config section.
Example of the account_lockout section:
auth_config:
#...
account_lockout:
attempt_threshold: 4
attempt_reset_duration: "1h"
#...
|
Parameter |
Description |
|
attempt_threshold |
Specifies the number of failed attempts to enter the correct password for a user account, after which the account is blocked for a period specified by the If Default value: |
|
attempt_reset_duration |
Specifies the period that a locked-out account remains locked before automatically becoming unlocked. This period starts after the last failed attempt. During this period, the user will not be able to authenticate in the system even if the correct username and password are entered. If this parameter is set to zero ("0s" - a notation equivalent of 0 seconds), user accounts will be locked indefinitely. In this case you can unlock the account using the ALTER USER ... LOGIN command. The minimum lockout duration is 1 second. Supported time units:
It is not allowed to combine time units in one entry. For example, the entry Default value: |
Configuring Password Complexity Requirements
YDB allows local users to authenticate using a login and password. For more information, see authentication by login and password. To enhance security in YDB, configure complexity requirements for the passwords of local users in the password_complexity subsection inside the auth_config section.
Example of the password_complexity section:
auth_config:
#...
password_complexity:
min_length: 8
min_lower_case_count: 1
min_upper_case_count: 1
min_numbers_count: 1
min_special_chars_count: 1
special_chars: "!@#$%^&*()_+{}|<>?="
can_contain_username: false
#...
|
Parameter |
Description |
|
min_length |
Specifies the minimum password length. Default value: |
|
min_lower_case_count |
Specifies the minimum number of lowercase letters that a password must contain. Default value: |
|
min_upper_case_count |
Specifies the minimum number of uppercase letters that a password must contain. Default value: |
|
min_numbers_count |
Specifies the minimum number of digits that a password must contain. Default value: |
|
min_special_chars_count |
Specifies the minimum number of special characters from the Default value: |
|
special_chars |
Specifies a list of special characters that are allowed in a password. Valid values: Default value: empty (any of the |
|
can_contain_username |
Indicates whether passwords can include a username. Default value: |
Note
Any changes to the password policy do not affect existing user passwords, so it is not necessary to change current passwords; they will be accepted as they are.
Configuring LDAP Authentication
One of the user authentication methods in YDB is using an LDAP directory. For more details, see Interacting with the LDAP directory. To configure LDAP authentication, define the ldap_authentication section inside the auth_config section.
Example of the ldap_authentication section:
auth_config:
#...
ldap_authentication:
hosts:
- "ldap-hostname-01.example.net"
- "ldap-hostname-02.example.net"
- "ldap-hostname-03.example.net"
port: 389
base_dn: "dc=mycompany,dc=net"
bind_dn: "cn=serviceAccaunt,dc=mycompany,dc=net"
bind_password: "serviceAccauntPassword"
search_filter: "uid=$username"
use_tls:
enable: true
ca_cert_file: "/path/to/ca.pem"
cert_require: DEMAND
ldap_authentication_domain: "ldap"
scheme: "ldap"
requested_group_attribute: "memberOf"
extended_settings:
enable_nested_groups_search: true
refresh_time: "1h"
#...
|
Parameter |
Description |
|
|
Specifies a list of hostnames where the LDAP server is running. |
|
|
Specifies the port used to connect to the LDAP server. |
|
|
Specifies the root of the subtree in the LDAP directory from which the user entry search begins. |
|
|
Specifies the Distinguished Name (DN) of the service account used to search for the user entry. |
|
|
Specifies the password for the service account used to search for the user entry. |
|
|
Specifies a filter for searching the user entry in the LDAP directory. The filter string can include the sequence $username, which is replaced with the username requested for authentication in the database. |
|
|
Configuration settings for the TLS connection between YDB and the LDAP server. |
|
|
Indicates whether a TLS connection using the |
|
|
Specifies the path to the certification authority's certificate file. |
|
|
Specifies the certificate requirement level for the LDAP server. Possible values:
|
|
|
Specifies an identifier appended to the username to distinguish LDAP directory users from those authenticated using other providers. Default value: |
|
|
Specifies the connection scheme to the LDAP server. Possible values:
Default value: |
|
|
Specifies the attribute used for reverse group membership. The default is |
|
|
Indicates whether to perform a request to retrieve the full hierarchy of groups to which the user's direct groups belong. Possible values:
Default value: |
|
|
Specifies the hostname of the LDAP server. This parameter is deprecated and should be replaced with the |
Configuring Third-Party IAM Authentication
YDB supports Yandex Identity and Access Management (IAM) used in Yandex Cloud for user authentication. To configure IAM authentication, define the following parameters:
|
Parameter |
Description |
|
use_access_service |
Indicates whether to allow authentication in Yandex Cloud using IAM AccessService. Default value: |
|
access_service_endpoint |
Specifies an IAM AccessService address, to which YDB sends requests. Default value: |
|
use_access_service_tls |
Indicates whether to use TLS connections between YDB and AccessService. Default value: |
|
access_service_domain |
Specifies an identifier appended to the username in SID to distinguish Yandex Cloud IAM users from those authenticated using other providers. Default value: |
|
path_to_root_ca |
Specifies the path to the certification authority's certificate file that is used to interact with AccessService. Default value: |
|
access_service_grpc_keep_alive_time_ms |
Specifies the period of time, in milliseconds, after which a keepalive ping is sent on the transport to IAM AccessService. Default value: |
|
access_service_grpc_keep_alive_timeout_ms |
Specifies the amount of time, in milliseconds, that YDB waits for the acknowledgement of the keepalive ping from IAM AccessService. If YDB does not receive an acknowledgment within this time, it will close the connection. Default value: |
|
use_access_service_api_key |
Indicates whether to use IAM API keys. The API key is a secret key created in Yandex Cloud IAM for simplified authorization of service accounts with the Yandex Cloud API. Use API keys if requesting an IAM token automatically is not an option. Default value: |
Configuring Caching for Authentication Results
During the authentication process, a user session receives an authentication token, which is transmitted along with each request to the cluster YDB. Since YDB is a distributed system, user requests will eventually be processed on one or more YDB nodes. After receiving a request from the user, a YDB node verifies the authentication token. If successful, the node generates a user token, which is valid only inside the current node and is used to authorize the actions requested by the user. Subsequent requests with the same authentication token to the same node do not require verification of the authentication token.
To configure the life cycle and other important aspects of managing user tokens, define the following parameters:
|
refresh_period |
Specifies how often a YDB node scans cached user tokens to find the ones that need to be refreshed because the Default value: |
|
refresh_time |
Specifies the time interval since the last user token update after which a YDB node updates the user token again. The actual update will occur within the range from Default value: |
|
life_time |
Specifies the time interval for keeping a user token in YDB node cache since its last use. If a YDB node does not receive queries from a user within the specified time interval, the node deletes the user token from its cache. Default value: |
|
expire_time |
Specifies the time period, after which a user token is deleted from YDB node cache. Deletion occurs regardless of the Warning If a third-party system has successfully authenticated in the YDB node and regularly (more often than the The shorter this time period, the more often YDB nodes re-authenticate users and refresh their privileges. However, excessive user re-authentication slows down YDB, especially so for external users. Setting this parameter to seconds negates the effect of caching user tokens. Default value: |
|
min_error_refresh_time |
Specifies minimum period of time that must elapse since a failed attempt (temporary failure) to refresh a user token before retrying the attempt. Together with the Warning Setting this parameter to Default value: |
|
max_error_refresh_time |
Specifies the maximum time interval that can elapse since a failed attempt (temporary failure) to refresh a user token before retrying the attempt. Together with the Default value: |