mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
wip
This commit is contained in:
39
auth/auth.go
Normal file
39
auth/auth.go
Normal file
@ -0,0 +1,39 @@
|
||||
package auth
|
||||
|
||||
type StreamingCredentialsProvider interface {
|
||||
// Subscribe subscribes to the credentials provider and returns a channel that will receive updates.
|
||||
// The first response is blocking, then data will be pushed to the channel.
|
||||
Subscribe(listener CredentialsListener) (Credentials, CancelProviderFunc, error)
|
||||
}
|
||||
|
||||
type CancelProviderFunc func() error
|
||||
|
||||
type CredentialsListener interface {
|
||||
OnNext(credentials Credentials)
|
||||
OnError(err error)
|
||||
}
|
||||
|
||||
type Credentials interface {
|
||||
BasicAuth() (username string, password string)
|
||||
RawCredentials() string
|
||||
}
|
||||
|
||||
type basicAuth struct {
|
||||
username string
|
||||
password string
|
||||
}
|
||||
|
||||
func (b *basicAuth) RawCredentials() string {
|
||||
return b.username + ":" + b.password
|
||||
}
|
||||
|
||||
func (b *basicAuth) BasicAuth() (username string, password string) {
|
||||
return b.username, b.password
|
||||
}
|
||||
|
||||
func NewCredentials(username, password string) Credentials {
|
||||
return &basicAuth{
|
||||
username: username,
|
||||
password: password,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user