Documentation
¶
Overview ¶
Package auth package provides authentication-related interfaces and types. It also includes a basic implementation of credentials using username and password.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials interface { // BasicAuth returns the username and password for basic authentication. BasicAuth() (username string, password string) // 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. RawCredentials() string }
Credentials is an interface that defines the methods for credentials. It is used to provide the credentials for authentication.
func NewBasicCredentials ¶
func NewBasicCredentials(username, password string) Credentials
NewBasicCredentials creates a new Credentials object from the given username and password.
type CredentialsListener ¶
type CredentialsListener interface { OnNext(credentials Credentials) OnError(err error) }
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.
type ReAuthCredentialsListener ¶
type ReAuthCredentialsListener struct {
// contains filtered or unexported fields
}
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.
func NewReAuthCredentialsListener ¶
func NewReAuthCredentialsListener(reAuth func(credentials Credentials) error, onErr func(err error)) *ReAuthCredentialsListener
NewReAuthCredentialsListener creates a new ReAuthCredentialsListener. Implements the auth.CredentialsListener interface.
func (*ReAuthCredentialsListener) OnError ¶
func (c *ReAuthCredentialsListener) OnError(err error)
OnError is called when an error occurs. It can be called from both the credentials provider and the reAuth function.
func (*ReAuthCredentialsListener) OnNext ¶
func (c *ReAuthCredentialsListener) OnNext(credentials Credentials)
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.
type StreamingCredentialsProvider ¶
type StreamingCredentialsProvider interface { // 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. // TODO(ndyakov): Should we add context to the Subscribe method? Subscribe(listener CredentialsListener) (Credentials, UnsubscribeFunc, error) }
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.
type UnsubscribeFunc ¶
type UnsubscribeFunc func() error
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.