auth

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthenticationFailed = errors.New("authentication failed")
	ErrTokenExpired         = errors.New("token expired")
	ErrBadRandomData        = errors.New("not enough random data")
)

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	AccessKey  string `gorm:"primary_key"`
	SecretKey  string
	User       string `gorm:"index:user_idx"`
	ValidUntil *time.Time
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GenerateAuthToken

func GenerateAuthToken(user string) (*AuthToken, error)

func (AuthToken) TableName

func (AuthToken) TableName() string

type AuthTokenDB

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

func NewAuthTokenDB

func NewAuthTokenDB(db *gorm.DB) *AuthTokenDB

func NewAuthTokenDBFromConfig

func NewAuthTokenDBFromConfig(c *config.CloudbuildOpts) (*AuthTokenDB, error)

func (*AuthTokenDB) Authenticate

func (at *AuthTokenDB) Authenticate(accessKey, secretKey string) error

func (*AuthTokenDB) CreateToken

func (at *AuthTokenDB) CreateToken(user string, validity *time.Duration) (*AuthToken, error)

func (*AuthTokenDB) ListTokens

func (at *AuthTokenDB) ListTokens() (*[]AuthToken, error)

func (*AuthTokenDB) RemoveToken

func (at *AuthTokenDB) RemoveToken(accessKey string) error

Jump to

Keyboard shortcuts

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