package auth

Import Path
	github.com/redis/go-redis/v9/auth (on go.dev)

Dependency Relation
	imports 0 packages, and imported by 2 packages

Involved Source Files Package auth package provides authentication-related interfaces and types. It also includes a basic implementation of credentials using username and password. reauth_credentials_listener.go
Package-Level Type Names (total 5)
/* sort by: | */
Credentials is an interface that defines the methods for credentials. It is used to provide the credentials for authentication. BasicAuth returns the username and password for basic authentication. RawCredentials returns the raw credentials as a string. This can be used to extract the username and password from the raw credentials or additional information if present in the token. func NewBasicCredentials(username, password string) Credentials func StreamingCredentialsProvider.Subscribe(listener CredentialsListener) (Credentials, UnsubscribeFunc, error) func CredentialsListener.OnNext(credentials Credentials) func (*ReAuthCredentialsListener).OnNext(credentials Credentials) func github.com/redis/go-redis/v9/internal/auth/streaming.(*ConnReAuthCredentialsListener).OnNext(credentials Credentials)
CredentialsListener is an interface that defines the methods for a credentials listener. It is used to receive updates when the credentials change. The OnNext method is called when the credentials change. The OnError method is called when an error occurs while requesting the credentials. ( CredentialsListener) OnError(err error) ( CredentialsListener) OnNext(credentials Credentials) *ReAuthCredentialsListener *github.com/redis/go-redis/v9/internal/auth/streaming.ConnReAuthCredentialsListener func github.com/redis/go-redis/v9/internal/auth/streaming.(*CredentialsListeners).Get(connID uint64) (CredentialsListener, bool) func github.com/redis/go-redis/v9/internal/auth/streaming.(*Manager).Listener(poolCn *pool.Conn, reAuth func(*pool.Conn, Credentials) error, onErr func(*pool.Conn, error)) (CredentialsListener, error) func StreamingCredentialsProvider.Subscribe(listener CredentialsListener) (Credentials, UnsubscribeFunc, error) func github.com/redis/go-redis/v9/internal/auth/streaming.(*CredentialsListeners).Add(connID uint64, listener CredentialsListener)
ReAuthCredentialsListener is a struct that implements the CredentialsListener interface. It is used to re-authenticate the credentials when they are updated. It contains: - reAuth: a function that takes the new credentials and returns an error if any. - onErr: a function that takes an error and handles it. OnError is called when an error occurs. It can be called from both the credentials provider and the reAuth function. OnNext is called when the credentials are updated. It calls the reAuth function with the new credentials. If the reAuth function returns an error, it calls the onErr function with the error. *ReAuthCredentialsListener : CredentialsListener func NewReAuthCredentialsListener(reAuth func(credentials Credentials) error, onErr func(err error)) *ReAuthCredentialsListener
StreamingCredentialsProvider is an interface that defines the methods for a streaming credentials provider. It is used to provide credentials for authentication. The CredentialsListener is used to receive updates when the credentials change. Subscribe subscribes to the credentials provider for updates. It returns the current credentials, a cancel function to unsubscribe from the provider, and an error if any. Implementations MUST be idempotent with respect to listener identity: subscribing the same listener value more than once must not produce duplicate notifications and must not create multiple independent subscriptions that each need to be cancelled separately. Every UnsubscribeFunc returned for a given listener must cancel that listener's subscription; calling any one of them must be sufficient to stop updates to that listener, and calling subsequent ones must be a safe no-op. Callers (including go-redis internals) may retain only the most recently returned UnsubscribeFunc and rely on it to fully unsubscribe the listener. TODO(ndyakov): Should we add context to the Subscribe method?
UnsubscribeFunc is a function that is used to cancel the subscription to the credentials provider. It is used to unsubscribe from the provider when the credentials are no longer needed. Per the StreamingCredentialsProvider.Subscribe contract, if the same listener is subscribed multiple times, every UnsubscribeFunc returned for that listener must fully unsubscribe it on first invocation, and subsequent invocations (from any of the equivalent UnsubscribeFuncs) must be a safe no-op. func StreamingCredentialsProvider.Subscribe(listener CredentialsListener) (Credentials, UnsubscribeFunc, error)
Package-Level Functions (total 2)
NewBasicCredentials creates a new Credentials object from the given username and password.
NewReAuthCredentialsListener creates a new ReAuthCredentialsListener. Implements the auth.CredentialsListener interface.