users

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Clients is an interface for retrieving cloud clients.
	Clients cloud.Clients
	// Clock is used to control time.
	Clock clockwork.Clock
	// Interval is the interval between user updates. Interval is also used as
	// the minimum password expiration duration.
	Interval time.Duration
	// Log is the logrus field logger.
	Log logrus.FieldLogger
	// UpdateMeta is used to update database metadata.
	UpdateMeta func(context.Context, types.Database) error
}

Config is the config for users service.

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config and set defaults.

type Fetcher

type Fetcher interface {
	// GetType returns the database type of the fetcher.
	GetType() string
	// FetchDatabaseUsers fetches users for provided database.
	FetchDatabaseUsers(ctx context.Context, database types.Database) ([]User, error)
}

Fetcher fetches database users for a particular database type.

type User

type User interface {
	// GetID returns a globally unique ID for the user.
	GetID() string
	// GetDatabaseUsername returns in-database username for the user.
	GetDatabaseUsername() string
	// Setup preforms any setup necessary like creating password secret.
	Setup(ctx context.Context) error
	// Teardown performs any teardown necessary like deleting password secret.
	Teardown(ctx context.Context) error
	// GetPassword returns the password used for database login.
	GetPassword(ctx context.Context) (string, error)
	// RotatePassword rotates user's password.
	RotatePassword(ctx context.Context) error
}

User represents a managed cloud database user.

type Users

type Users struct {
	// contains filtered or unexported fields
}

Users manages database users for cloud databases.

func NewUsers

func NewUsers(cfg Config) (*Users, error)

NewUsers returns a new instance of users service.

func (*Users) GetPassword

func (u *Users) GetPassword(ctx context.Context, database types.Database, username string) (string, error)

GetPassword returns the password for database login.

func (*Users) Setup

func (u *Users) Setup(_ context.Context, database types.Database) error

Setup starts to discover and manage users for provided database.

Setup allows managed database users to become available as soon as new database is registered instead of waiting for the periodic setup goroutine. Note that there is no corresponding "Teardown" as cleanup will eventually happen in the periodic setup.

func (*Users) Start

func (u *Users) Start(ctx context.Context, getAllDatabases func() types.Databases)

Start starts users service to manage cloud database users.

Jump to

Keyboard shortcuts

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