Skip to content

Configure Valkey Authentication

By default, when connecting to Valkey, Valkey GLIDE operates in an unauthenticated mode.

Valkey GLIDE also offers support for an authenticated connection mode.

In authenticated mode, you have the following options:

  • Use both a username and password, which is recommended and configured through ACLs on the server.
  • Use a password only, which is applicable if the server is configured with the requirepass setting.

To provide the necessary authentication credentials to the client, you can use the ServerCredentials class.

See the Dynamic Authentication section for a detailed explanation about using ACLs with GLIDE.

Both standalone and cluster mode support authentication authentication with username and password.

from glide import (
GlideClient,
GlideClientConfiguration,
ServerCredentials,
NodeAddress
)
addresses = [
NodeAddress(host="primary.example.com", port=6379),
NodeAddress(host="replica1.example.com", port=6379),
NodeAddress(host="replica2.example.com", port=6379)
]
credentials = ServerCredentials("passwordA", "user1")
client_config = GlideClientConfiguration(addresses, credentials=credentials)
client = await GlideClient.create(client_config)
from glide import (
GlideClusterClient,
GlideClusterClientConfiguration,
ServerCredentials,
NodeAddress
)
addresses = [NodeAddress(host="address.example.com", port=6379)]
credentials = ServerCredentials("passwordA", "user1")
client_config = GlideClusterClientConfiguration(addresses, credentials=credentials)
client = await GlideClusterClient.create(client_config)
  • Regular Credential Rotation — Frequently update passwords and tokens using Dynamic Authentication to maintain secure connections.
  • Automate Token Refreshing — Implement automated mechanisms to refresh IAM tokens before they expire. See IAM Integration for cloud-specific patterns.
  • Secure Credential Storage — Store passwords and tokens securely using environment variables or secret management tools. Never hardcode credentials in source code or configuration files checked into version control.
  • Principle of Least Privilege — Use ACLs to assign minimal necessary permissions to users. Avoid using the default user for application connections.