auth

package
v0.0.0-test3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default cost is 10
	DefaultBcryptCost      = bcrypt.DefaultCost
	DefaultCacheExpiration = 10 * time.Minute
)

Variables

View Source
var (
	ErrUserExists   = errors.New("user already exists")
	ErrNoUserExists = errors.New("no user exists")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled                bool          `toml:"enabled"`
	CacheExpiration        toml.Duration `toml:"cache-expiration"`
	BcryptCost             int           `toml:"bcrypt-cost"`
	MetaAddr               string        `toml:"meta-addr"`
	MetaUsername           string        `toml:"meta-username"`
	MetaPassword           string        `toml:"meta-password"`
	MetaUseTLS             bool          `toml:"meta-use-tls"`
	MetaCA                 string        `toml:"meta-ca"`
	MetaCert               string        `toml:"meta-cert"`
	MetaKey                string        `toml:"meta-key"`
	MetaInsecureSkipVerify bool          `toml:"meta-insecure-skip-verify"`
}

func NewDisabledConfig

func NewDisabledConfig() Config

func NewEnabledConfig

func NewEnabledConfig() Config

func (Config) Validate

func (c Config) Validate() error

type Diagnostic

type Diagnostic interface {
	Debug(msg string, ctx ...keyvalue.T)
}

type Privilege

type Privilege int
const (
	NoPrivileges Privilege = iota

	ReadPrivilege
	WritePrivilege
	DeletePrivilege

	AllPrivileges
)

type Service

type Service struct {
	StorageService interface {
		Store(namespace string) storage.Interface
	}
	HTTPDService interface {
		AddRoutes([]httpd.Route) error
		DelRoutes([]httpd.Route)
	}
	// contains filtered or unexported fields
}

func NewService

func NewService(c Config, d Diagnostic) (*Service, error)

func (*Service) Authenticate

func (s *Service) Authenticate(username, password string) (auth.User, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) CreateUser

func (s *Service) CreateUser(username, password string, admin bool, privileges map[string][]Privilege) (User, error)

func (*Service) DeleteUser

func (s *Service) DeleteUser(username string)

func (*Service) GrantSubscriptionAccess

func (s *Service) GrantSubscriptionAccess(token, db, rp string) error

func (*Service) ListSubscriptionTokens

func (s *Service) ListSubscriptionTokens() ([]string, error)

func (*Service) Open

func (s *Service) Open() error

func (*Service) RevokeSubscriptionAccess

func (s *Service) RevokeSubscriptionAccess(token string) error

func (*Service) SubscriptionUser

func (s *Service) SubscriptionUser(token string) (auth.User, error)

Return a user based on the subscription token

func (*Service) User

func (s *Service) User(username string) (auth.User, error)

type User

type User struct {
	Name       string
	Admin      bool
	Hash       []byte
	Privileges map[string][]Privilege
}

A user with is set of permissions

func (User) MarshalBinary

func (u User) MarshalBinary() ([]byte, error)

func (User) ObjectID

func (u User) ObjectID() string

func (*User) UnmarshalBinary

func (u *User) UnmarshalBinary(data []byte) error

type UserCache

type UserCache interface {
	Get(username string) (auth.User, bool)
	Set(auth.User)
	Delete(username string)
	DeleteAll()
}

type UserDAO

type UserDAO interface {
	// Retrieve a user
	Get(username string) (User, error)

	// Create a user.
	// ErrUserExists is returned if a user already exists with the same username.
	Create(u User) error

	// Replace an existing user.
	// ErrNoUserExists is returned if the user does not exist.
	Replace(u User) error

	// Delete a user.
	// It is not an error to delete an non-existent user.
	Delete(username string) error

	// List users matching a pattern on username.
	// The pattern is shell/glob matching see https://golang.org/pkg/path/#Match
	// Offset and limit are pagination bounds. Offset is inclusive starting at index 0.
	// More results may exist while the number of returned items is equal to limit.
	List(pattern string, offset, limit int) ([]User, error)
}

Directories

Path Synopsis
Package meta provides a client to the meta node to allow Kapacitor to perform auth.
Package meta provides a client to the meta node to allow Kapacitor to perform auth.

Jump to

Keyboard shortcuts

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