authn

package
v0.0.0-...-7d2a9e7 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExpiredToken = errors.New("expired token")

Functions

func NewStaticUserAuth

func NewStaticUserAuth(users map[string]*Requirements) *staticUsersAuth

Types

type PluginAuthn

type PluginAuthn struct {
	Authn api.Authenticator
	// contains filtered or unexported fields
}

func NewPluginAuthn

func NewPluginAuthn(cfg *PluginAuthnConfig) (*PluginAuthn, error)

func (*PluginAuthn) Authenticate

func (c *PluginAuthn) Authenticate(user string, password api.PasswordString) (bool, api.Labels, error)

func (*PluginAuthn) Name

func (c *PluginAuthn) Name() string

func (*PluginAuthn) Stop

func (c *PluginAuthn) Stop()

type PluginAuthnConfig

type PluginAuthnConfig struct {
	PluginPath string `yaml:"plugin_path"`
}

func (*PluginAuthnConfig) Validate

func (c *PluginAuthnConfig) Validate() error

type Requirements

type Requirements struct {
	Password *api.PasswordString `yaml:"password,omitempty" json:"password,omitempty"`
	Labels   api.Labels          `yaml:"labels,omitempty" json:"labels,omitempty"`
}

func (Requirements) String

func (r Requirements) String() string

type TokenDB

type TokenDB interface {
	// GetValue takes a username returns the corresponding token
	GetValue(string) (*TokenDBValue, error)

	// StoreToken takes a username and token, stores them in the DB
	// and returns a password and error
	StoreToken(string, *TokenDBValue, bool) (string, error)

	// ValidateTOken takes a username and password
	// and returns an error
	ValidateToken(string, api.PasswordString) error

	// DeleteToken takes a username
	// and deletes the corresponding token from the DB
	DeleteToken(string) error

	// Composed from leveldb.DB
	Close() error
}

TokenDB stores tokens using LevelDB

func NewTokenDB

func NewTokenDB(file string) (TokenDB, error)

NewTokenDB returns a new TokenDB structure

type TokenDBImpl

type TokenDBImpl struct {
	*leveldb.DB
}

TokenDB stores tokens using LevelDB

func (*TokenDBImpl) DeleteToken

func (db *TokenDBImpl) DeleteToken(user string) error

func (*TokenDBImpl) GetValue

func (db *TokenDBImpl) GetValue(user string) (*TokenDBValue, error)

func (*TokenDBImpl) StoreToken

func (db *TokenDBImpl) StoreToken(user string, v *TokenDBValue, updatePassword bool) (dp string, err error)

func (*TokenDBImpl) ValidateToken

func (db *TokenDBImpl) ValidateToken(user string, password api.PasswordString) error

type TokenDBValue

type TokenDBValue struct {
	TokenType    string    `json:"token_type,omitempty"` // Usually "Bearer"
	AccessToken  string    `json:"access_token,omitempty"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	ValidUntil   time.Time `json:"valid_until,omitempty"`
	// DockerPassword is the temporary password we use to authenticate Docker users.
	// Generated at the time of token creation, stored here as a BCrypt hash.
	DockerPassword string     `json:"docker_password,omitempty"`
	Labels         api.Labels `json:"labels,omitempty"`
}

TokenDBValue is stored in the database, JSON-serialized.

Jump to

Keyboard shortcuts

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