auth

package
v0.0.0-...-d26c344 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCredentialsInvalid = errors.New("invalid credentials")
View Source
var ErrTokenInvalid = errors.New("invalid token")

Functions

func CreateLoginToken

func CreateLoginToken(db db.TxHandler, email string) (core.User, string, error)

func CreateResetToken

func CreateResetToken(db db.TxHandler, email string) (core.User, string, error)

func GenerateAPIKey

func GenerateAPIKey(db db.TxHandler, userID int32, validity time.Duration, description string, scopes []string) (id, key string, err error)

func GenerateAPIToken

func GenerateAPIToken(db db.TxHandler, userID int32, validity time.Duration, description string, scopes []string) (string, error)

func Initialize

func Initialize(cfg Config, log zerolog.Logger) error

func MagicLinksEnabled

func MagicLinksEnabled() bool

func OpenIDProviders

func OpenIDProviders() []openid.Provider

func OpenIDStart

func OpenIDStart(db db.Handler, providerName, redirectURI string, clientType OpenIDClientType) (string, error)

func PasswordAuthEnabled

func PasswordAuthEnabled() bool

func PasswordResetEnabled

func PasswordResetEnabled() bool

func RevokeAPIKey

func RevokeAPIKey(db db.Handler, keyIDStr string, delete bool) error

func UpdateUserPassword

func UpdateUserPassword(db db.TxHandler, email, password string) error

Types

type APIKey

type APIKey struct {
	ID          string
	Created     time.Time
	Expires     pgtype.Timestamptz
	Description string
	Scopes      []string
}

func ListAPIKeys

func ListAPIKeys(db db.Handler, userID int32, includeExpired bool) ([]APIKey, error)

type Auth

type Auth interface {
	UserID() int32
	UserPermissions() core.UserPermissions
	HasScope(scope string) bool
	GetFileSystem(db db.Handler, rootOverride pgtype.UUID) *core.FileSystem
}

func PerformPasswordLogin

func PerformPasswordLogin(db db.TxHandler, email, password string) (auth Auth, key string, err error)

func PerformTokenLogin

func PerformTokenLogin(db db.TxHandler, encodedToken string) (Auth, string, error)

func ReadAPIKey

func ReadAPIKey(db db.Handler, keyIDStr, keyStr string) (Auth, error)

func ReadAPIToken

func ReadAPIToken(db db.Handler, encodedKey string) (Auth, error)

func ResetUserPassword

func ResetUserPassword(db db.TxHandler, email, resetToken, password string) (a Auth, key string, err error)

func VerifyUserPassword

func VerifyUserPassword(d db.Handler, email, password string) (Auth, error)

type Config

type Config struct {
	AutoCreate []string       `koanf:"auto_create"`
	Password   PasswordConfig `koanf:"password"`
	MagicLink  bool           `koanf:"magic_link"`
	OpenID     openid.Config  `koanf:"openid"`
}

type OpenIDClientType

type OpenIDClientType uint8
const (
	OpenIDClientNone OpenIDClientType = iota
	OpenIDClientWeb
	OpenIDClientNative
)

func OpenIDValidateAuthCode

func OpenIDValidateAuthCode(d db.Handler, state, authCode, redirectURI string) (OpenIDClientType, error)

type PasswordBackend

type PasswordBackend interface {
	SupportsPasswordUpdate() bool
	VerifyUserPassword(db db.Handler, email, password string) (bool, error)
	UpdateUserPassword(db db.Handler, email, password string) error
}

type PasswordConfig

type PasswordConfig struct {
	Backend      string               `koanf:"backend"`
	ResetEnabled bool                 `koanf:"reset_enabled"`
	Crypt        crypt.Config         `koanf:"crypt"`
	LDAP         ldap.Config          `koanf:"ldap"`
	Requirements PasswordRequirements `koanf:"requirements"`
}

type PasswordRequirements

type PasswordRequirements struct {
	Length  int `koanf:"length"`
	Lower   int `koanf:"lower"`
	Upper   int `koanf:"upper"`
	Numeric int `koanf:"numeric"`
	Symbols int `koanf:"symbols"`
}

type PasswordStrengthError

type PasswordStrengthError struct {
	Reason string
}

func (PasswordStrengthError) Error

func (e PasswordStrengthError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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