auth_config
- Configuring authentication for local users YDB
- LDAP authentication configuration
- Configuring client certificate authentication
- Configuring authentication using an external IdP
- Configuring authentication with a third-party IAM provider
- Authentication result caching settings
- Node registration token configuration
YDB allows using various methods of user authentication in the system. Authentication settings and authentication providers are set in the auth_config section of the YDB configuration file.
Configuring authentication for local users YDB
For more information about authentication of local users, see the section on login and password authentication. To configure authentication of local users by login and password, specify the following parameters in the auth_config section:
|
Parameter |
Description |
|
|
The flag enables authentication of local users using auth tokens obtained as a result of login with a username and password. The login procedure in YDB is the exchange of a username and password for an authentication token. Possible values:
Default value: Note For the ability to create and authenticate local users, the |
|
|
The flag enables creation of local users and obtaining an authentication token for them in exchange for a username and password. Possible values:
Default value: |
|
|
The flag defines the scope of access rights for local users in the YDB cluster. Possible values:
Default value: |
|
|
Lifetime of the authentication token created in exchange for the local user's username and password. Default value: |
Configuring user lockout on incorrect password
YDB allows you to prevent a user from authenticating if they have made several unsuccessful password attempts. To configure the user lockout conditions, fill in the account_lockout section.
Example of the account_lockout section:
auth_config:
#...
account_lockout:
attempt_threshold: 4
attempt_reset_duration: "1h"
#...
|
Parameter |
Description |
|
|
Number of incorrect password attempts after which the user account is temporarily blocked. If the user enters the wrong password the specified number of times in a row, they are prohibited from authenticating for the time set in the If the parameter is set to Default value: |
|
|
The period of time during which the user is considered blocked. During this period, the user will not be able to authenticate to the system even if they enter the correct username and password. The blocking period starts from the moment of the last incorrect password attempt. If a zero value is specified ( The minimum blocking time interval is 1 second. Supported units of measurement:
Combining units of measurement in a single line is not allowed. For example, the following entry is incorrect: Default value: |
Configuring password complexity requirements
YDB allows authenticating users by login and password. For more details, see the section login and password authentication. To improve security, YDB provides the ability to configure the complexity of passwords used by local users. To configure password requirements, you need to describe the password_complexity 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 |
|
|
Minimum password length. Default value: |
|
|
Minimum number of lowercase letters in the password. Default value: |
|
|
Minimum number of uppercase letters in the password. Default value: |
|
|
Minimum number of digits in the password. Default value: |
|
|
Minimum number of special characters in the password from those specified in the Default value: |
|
|
List of special characters allowed when setting a password. Valid values: Default value: empty string (allows all valid special characters) |
|
|
The flag determines whether the username can be included in the password. Default value: |
Note
Any changes to the password policy do not affect existing user passwords, so there is no need to change existing passwords; they will be accepted as is.
LDAP authentication configuration
One way to authenticate users in YDB is to use an LDAP directory. More about this type of authentication is described in the section on using an LDAP directory. To configure LDAP authentication, you need to describe the ldap_authentication 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"
scheme: "ldap"
requested_group_attribute: "memberOf"
extended_settings:
enable_nested_groups_search: true
enable_sasl_external_bind: true
use_tls:
enable: true
ca_cert_file: "/path/to/ca.pem"
cert_require: DEMAND
cert_file: "/path/to/client-cert.pem"
key_file: "/path/to/client-key.pem"
ldap_authentication_domain: "ldap"
refresh_time: "1h"
#...
|
Parameter |
Description |
|
|
List of host names on which the LDAP server runs |
|
|
Port for connecting to the LDAP server |
|
|
Root of the subtree in the LDAP directory from which the user record search will be performed |
|
|
Distinguished Name (DN) of the service account on whose behalf the user record search is performed |
|
|
Password of the service account on whose behalf the user record search is performed. Not set when |
|
|
Filter for searching the user record in the LDAP directory. The filter string may contain the character sequence $username, which will be replaced with the user name requested for authentication in the database |
|
|
Settings for configuring the TLS connection between YDB and the LDAP server |
|
|
Determines whether an attempt will be made to establish a TLS connection using the |
|
|
Path to the certificate authority file |
|
|
Level of requirements for the LDAP server certificate. Possible values:
Default value: |
|
|
Path to the client certificate file. Used as authentication information for the service account. |
|
|
Path to the client certificate key file |
|
|
LDAP server connection scheme. Possible values:
Default value: |
|
|
Attribute of reverse group membership. Default: |
|
|
Flag that determines whether a query is executed to retrieve the entire tree of groups that include the user's direct groups. Possible values:
Default value: |
|
|
Flag that determines whether service account authentication is performed using the SASL protocol with the EXTERNAL mechanism. Possible values:
Default value: |
|
|
Host name where the LDAP server runs. This is a deprecated parameter; the |
|
|
User name suffix that distinguishes users from the LDAP directory from users authenticated by other providers. Default value: |
Configuring client certificate authentication
YDB supports client certificate authentication. Certificate verification rules are set in the client_certificate_authorization section. Additionally, the auth_config section may specify a suffix for user names authenticated by certificate:
|
Parameter |
Description |
|
|
User name suffix that distinguishes users authenticated by client certificate from users authenticated by other methods. Default value: |
Configuring authentication using an external IdP
YDB supports authentication using JWT tokens of an external identity provider via OpenID Connect. To enable authentication, add the external_idp_config section to auth_config.
Configuration example:
auth_config:
#...
external_idp_config:
issuer: "https://idp.example.com"
audience: "ydb-cluster"
allowed_clock_skew: "30s"
subject_claim_name: "username"
groups_claim_name: "groups"
discovery_periodic_settings:
success_refresh_period: "1h"
min_error_refresh_period: "1s"
max_error_refresh_period: "5m"
request_timeout: "15s"
jwks_periodic_settings:
success_refresh_period: "30m"
min_error_refresh_period: "1s"
max_error_refresh_period: "10s"
request_timeout: "15s"
jwks_cache_settings:
timeout: "2h"
external_idp_authentication_domain: "sso"
use_access_service: false
#...
|| external_idp_config.issuer
| Expected value of the iss field (issuer), which identifies the issuer of the JWT token, and the base URL for OIDC Discovery. Required parameter; must start with https:// and must not end with the character /. The values of issuer in the Discovery document and iss in the JWT must exactly match the specified value.
Default value: empty string
||
|| external_idp_config.audience
| Expected value of the aud field (audience), which identifies the recipient of the JWT token. If the parameter is not set, the token recipient is not checked.
Default value: empty string
||
|| external_idp_config.allowed_clock_skew
| Allowed clock skew when checking JWT time-related fields: exp sets the token expiration time, nbf sets the token start time, iat sets the issue time.
Default value: 30s
||
|| external_idp_config.subject_claim_name
| Name of the JWT string field from which the user SID is formed. If the field is missing or has a different type, the sub field is used.
Default value: sub
||
|| external_idp_config.groups_claim_name
| Name of the JWT field with an array of user groups. Only string elements are extracted from the array.
Default value: groups
||
|| external_idp_config.discovery_periodic_settings.success_refresh_period
| Discovery document refresh period after a successful request.
Default value: 1h
||
|| external_idp_config.discovery_periodic_settings.min_error_refresh_period
| Minimum interval before re-requesting the Discovery document after an error.
Default value: 1s
||
|| external_idp_config.discovery_periodic_settings.max_error_refresh_period
| Maximum interval before re-requesting the Discovery document after an error.
Default value: 5m
||
|| external_idp_config.discovery_periodic_settings.request_timeout
| Discovery document request timeout.
Default value: 15s
||
|| external_idp_config.jwks_periodic_settings.success_refresh_period
| JWKS refresh period after a successful request.
Default value: 1h
||
|| external_idp_config.jwks_periodic_settings.min_error_refresh_period
| Minimum interval before re-requesting JWKS after an error.
Default value: 1s
||
|| external_idp_config.jwks_periodic_settings.max_error_refresh_period
| Maximum interval before re-requesting JWKS after an error.
Default value: 5m
||
|| external_idp_config.jwks_periodic_settings.request_timeout
| JWKS request timeout.
Default value: 15s
||
|| external_idp_config.jwks_cache_settings.timeout
| Maximum age of the JWKS cache. If JWKS cannot be updated, the keys are removed after this period expires.
Default value: 2h
||
|| external_idp_authentication_domain
| User name suffix that distinguishes external IdP users from users authenticated by other providers. The same suffix is added to group names obtained from the JWT token.
Default value: sso
||
|#
Warning
Third-party IAM provider and external IdP over OIDC use tokens of type Bearer. If the use_access_service parameter is enabled, the IAM provider takes priority and intercepts all such tokens. Therefore, simultaneous use of authentication via an IAM provider and an external IdP over OIDC is not supported.
Configuring authentication with a third-party IAM provider
YDB supports user authentication using the Yandex Identity and Access Management (IAM) service, which is used in Yandex Cloud, or another service compatible with it via API. To configure IAM authentication, define the following parameters:
|
Parameter |
Description |
|
|
Flag enables user authentication in Yandex Cloud via IAM using AccessService. Default value: |
|
|
Address to which requests are sent to AccessService (IAM). Default value: |
|
|
Flag enables the use of TLS connections between YDB and AccessService. Default value: |
|
|
Suffix of the 'user source' in SID for users coming to YDB from Yandex Cloud IAM. Default value: |
|
|
Path to the certificate file of the certificate authority used for interaction with AccessService. Default value: |
|
|
Time period, in milliseconds, after which YDB sends a keepalive ping to the IAM server to keep the connection alive. Default value: |
|
|
Time period to wait for a response from the IAM server to a keepalive ping, in milliseconds. If no response is received from the IAM server within the timeout, YDB closes the connection. Default value: |
|
|
The flag enables the use of IAM API keys. An API key is a secret key issued in Yandex Cloud IAM for simplified authorization of service accounts in the Yandex Cloud API. It is used when it is not possible to automatically request an IAM token. Default value: |
Authentication result caching settings
To reduce the number of authentication token checks, each YDB node caches the verification results in user tokens. For more details, see the article Caching authentication results.
The lifetime and other aspects of user token operation are configured using the following parameters. Time parameter values are specified as a number with a unit suffix: ms — milliseconds, s — seconds, m — minutes, h — hours, d — days. For example, 300ms, 30s, 10m, 1h, or 2d.
|
|
Determines how often the YDB node scans user tokens in the cache for reaching the time limits specified in the Default value: |
|
|
Maximum interval between a successful user token refresh and the next refresh attempt. The specific refresh time is chosen in the range from For example, after the first request with a valid authentication token, the node creates a user token. After an interval randomly selected in the range from The parameter applies to refreshable authentication tokens, for example, to login and password tokens and tokens of an external identity provider. Default value: |
|
|
The period of storage of the user token in the cache of node YDB since its last use. If no requests from the user for whom the token was created have arrived at node YDB within the specified period, the node removes this user token from its cache. Default value: |
|
|
The validity period of the result of a successful check for most types of authentication tokens. After a successful update, the countdown starts over. After the period expires, the entry is removed from the cache regardless of For login and password tokens and tokens of an external identity provider, the expiration time of the authentication token itself is used. For requests signed with an access key, a separate parameter Default value: |
|
|
The validity period of the check result of a request authenticated using an access key signature. Default value: |
|
|
The initial interval between retries after a retryable error in updating the user token. After a retryable error, the first re-check is performed immediately. If it also ends with a retryable error, the delay before the next check is chosen randomly in the range from Warning It is not recommended to set the parameter value to Default value: |
|
|
Limits the increase of the interval between re-checks after retryable errors of user token refresh. Does not limit the total duration of re-checks. Default value: |
Example for authentication by login and password:
auth_config:
refresh_period: "1s"
refresh_time: "1h"
life_time: "2h"
expire_time: "6h"
login_token_expire_time: "12h"
min_error_refresh_time: "1s"
max_error_refresh_time: "1m"
After a user token is created, the next scheduled check is performed after an interval randomly selected in the range from 30m to 1h (refresh_time). This condition is checked once every 1s (refresh_period). After a successful check, a new interval is selected. If a retryable error occurs, the first retry check is performed immediately. If it also ends with a retryable error, the next check is performed after an interval randomly selected in the range from 500ms to 1s (min_error_refresh_time). Then the current interval is doubled, but does not exceed 59s (max_error_refresh_time - min_error_refresh_time). The actual delay is randomly selected each time in the range from half to the full current interval.
For an authentication token obtained by login and password, the expire_time parameter does not apply: the validity period of such a token is set by login_token_expire_time, so it becomes invalid after 12h. The cached entry stops being used at the nearest check after this condition, but may be deleted earlier due to lack of requests for 2h (life_time) or a persistent error.
Example for queries signed with an access key:
auth_config:
refresh_period: "1s"
life_time: "30m"
as_signature_expire_time: "1h"
The user token for a query signed with an access key is not updated on a schedule. The entry is considered valid for 1h (as_signature_expire_time) from the moment of successful verification and is deleted at the nearest cache check. With the specified values, it will be deleted no later than after 1h + 1s (as_signature_expire_time + refresh_period). The entry may be deleted earlier due to lack of requests for 30m (life_time).
Node registration token configuration
YDB allows you to configure the authentication type of database nodes when they are registered in the cluster. This type is configured via the node_registration_token parameter of the auth_config section.
|
Parameter |
Description |
|
|
Defines the authentication type of database nodes when they are registered in the cluster YDB. Possible values:
|
Example of the auth_config section with node registration configured by certificate:
auth_config:
#...
node_registration_token: ""
#...