auth

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredentials = errors.New("invalid username or password")

Functions

func HashPassword

func HashPassword(value string) (string, error)

func NormalizeUsername

func NormalizeUsername(value string) string

func ValidatePassword

func ValidatePassword(value string) error

func ValidateRole

func ValidateRole(role string) error

func ValidateUsername

func ValidateUsername(value string) error

Types

type Config

type Config struct {
	SessionTTL   time.Duration
	CookieName   string
	CookieSecure bool
}

type LoginLimiter

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

func NewLoginLimiter

func NewLoginLimiter() *LoginLimiter

func (*LoginLimiter) Allow

func (l *LoginLimiter) Allow(key string) (bool, time.Duration)

func (*LoginLimiter) Failure

func (l *LoginLimiter) Failure(key string)

func (*LoginLimiter) Success

func (l *LoginLimiter) Success(key string)

type Service

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

func New

func New(dataStore store.Store, cfg Config) *Service

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, token string) (model.User, error)

func (*Service) ClearSessionCookie

func (s *Service) ClearSessionCookie(w http.ResponseWriter)

func (*Service) EnsureBootstrapAdmin

func (s *Service) EnsureBootstrapAdmin(ctx context.Context, username, password string) error

func (*Service) Login

func (s *Service) Login(ctx context.Context, username, password string) (model.User, string, time.Time, error)

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, token string) error

func (*Service) SetSessionCookie

func (s *Service) SetSessionCookie(w http.ResponseWriter, token string, expiresAt time.Time)

func (*Service) TokenFromRequest

func (s *Service) TokenFromRequest(r *http.Request) string

Jump to

Keyboard shortcuts

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