credentials

package
v19.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAzureScope = "https://redis.azure.com/.default"

DefaultAzureScope is the OAuth scope for Azure Cache for Redis and Azure Managed Redis.

Variables

This section is empty.

Functions

func AuthCredentials

func AuthCredentials(ctx context.Context, p Provider, leeway time.Duration) (rueidis.AuthCredentials, error)

AuthCredentials fetches credentials from p and adapts them to rueidis.AuthCredentials. RefreshAfter is set to leeway before the token expires, so rueidis re-authenticates live connections before the server rejects them. A zero expiry leaves RefreshAfter unset, which relies on reconnect-time authentication instead.

Types

type AzureOptions

type AzureOptions struct {
	// AuthType selects how the token is acquired. "" or "default" uses the Azure
	// default credential chain, which covers workload identity, managed
	// identity, and environment credentials. "managed_identity" pins to the
	// instance's managed identity (optionally a user-assigned one via ClientID).
	AuthType string
	// ObjectID is the object (principal) ID of a user-assigned managed identity.
	// Empty means the system-assigned identity. Only used with managed-identity
	// auth.
	ObjectID string
	// Scope overrides DefaultAzureScope when set.
	Scope string
	// Username is the AUTH username. When empty, it is derived from the token's
	// oid claim (the managed identity or service principal object ID).
	Username string
}

AzureOptions configures the Azure (Microsoft Entra) credentials provider.

type Provider

type Provider interface {
	// Credentials returns the AUTH username, the token to use as the password,
	// and the time the token expires.
	Credentials(ctx context.Context) (username, token string, expiresAt time.Time, err error)
}

Provider returns Redis AUTH credentials backed by a short-lived, rotating token (for example a Microsoft Entra token), refreshing the token as needed. Implementations must be safe for concurrent use.

func NewAzure

func NewAzure(opts AzureOptions) (Provider, error)

NewAzure builds a Provider that authenticates to Redis with a Microsoft Entra token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL