auth

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCredentials    = errors.New("invalid credentials")
	ErrUserAlreadyExists     = errors.New("user already exists")
	ErrUnsupportedProvider   = errors.New("auth provider is not supported")
	ErrAccountExistsMustLink = errors.New("account exists; must link provider explicitly")
	ErrUsernameTaken         = errors.New("username already taken")
	ErrInvalidUsername       = errors.New("invalid username")
	ErrNoRolesInContext      = errors.New("no roles in context for user")
	ErrEmailNotAllowed       = errors.New("email is not allowed to access the application")
)

Functions

func Hash

func Hash(password string) (string, error)

func SanitizeUsername

func SanitizeUsername(s string) string

sanitizeUsername: - keeps only [a-zA-z0-9_-] - turns runs of other chars into a single '-' - trims leading/trailing '-' and '_'

func SecureFiveDigits

func SecureFiveDigits() (int64, error)

func ValidateUsername

func ValidateUsername(username string) error

func Verify

func Verify(password, encoded string) (bool, error)

Types

type Config

type Config struct {
	Store            *store.Store
	Tx               *tx.Manager
	WebhookPublisher webhook.Publisher
	Logger           *slog.Logger
	AccessPolicy     accesspolicy.EmailAccessPolicy
}

type CurrentUser

type CurrentUser struct {
	User  domain.User
	Roles []roles.Role
}

type LoginInput

type LoginInput struct {
	Provider domain.Provider

	Username string
	Email    string
	Password string

	OAuthID string
}

type Service

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

func New

func New(cfg Config) *Service

func (*Service) ChangeUsername

func (s *Service) ChangeUsername(ctx context.Context, userID uuid.UUID, username string) error

func (*Service) DeleteUser

func (s *Service) DeleteUser(ctx context.Context, userID uuid.UUID) error

func (*Service) DisableUser

func (s *Service) DisableUser(ctx context.Context, userID uuid.UUID) error

func (*Service) GetCurrentUser

func (s *Service) GetCurrentUser(ctx context.Context, userID uuid.UUID) (*CurrentUser, error)

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, userID uuid.UUID) (*domain.User, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, in LoginInput) (*domain.User, error)

func (*Service) Signup

func (s *Service) Signup(ctx context.Context, in SignupInput) (*domain.User, error)

type SignupInput

type SignupInput struct {
	Provider domain.Provider

	Username string
	Email    string
	Password string

	OAuthID string
}

Jump to

Keyboard shortcuts

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