auth

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginInput

type LoginInput struct {
	Email      string `json:"email,omitempty"`
	MemberName string `json:"membername,omitempty"`
	Password   string `json:"password"`
	RememberMe bool   `json:"remember_me"`
}

LoginInput is the input for the login request

func (LoginInput) Validate

func (l LoginInput) Validate() (*member.Input, error)

type RegLoginInput

type RegLoginInput interface {
	RegisterInput | LoginInput
}

RegLoginInput is an union (feature introduced in Go 1.18) of RegisterInput and LoginInput

type RegisterInput

type RegisterInput struct {
	Email      string `json:"email"`
	MemberName string `json:"membername"`
	// Password is first temporarily encrypted using RSA and then hashed using argon2id
	// For more details see the internal/crypt package
	Password        string   `json:"password"`
	PasswordConfirm string   `json:"passwordConfirm"`
	Roles           []string `json:"roles"`
}

RegisterInput is the input for the registration request

func (RegisterInput) Validate

func (r RegisterInput) Validate() (*member.Input, error)

type Service added in v0.6.2

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

Service allows dependency injection for the controller methods, so that the db connection needn't be created in the controller methods

func NewService added in v0.6.2

func NewService(
	conf *cfg.Config,
	ms member.MemberStorer,
	log *zerolog.Logger,
	sess *session.Store,
) *Service

NewService creates an instance of the Service struct and returns a pointer to it It should be used within the routes package where the db connection and config are passed from the main package

func (*Service) GetAuthStatus added in v0.7.0

func (a *Service) GetAuthStatus(c *fiber.Ctx) error

func (*Service) GetSessionTimeoutPrefs added in v0.7.0

func (a *Service) GetSessionTimeoutPrefs(rememberMe bool) (timeout time.Duration, err error)

GetSessionTimeoutPrefs returns the session timeout preferences Currently, only support for "remember me" is implemented

func (*Service) Login added in v0.6.2

func (a *Service) Login(c *fiber.Ctx) error

1. Parse the input 2. Validate the input (check for empty fields, valid email, etc.) 3. Pass the email to the database, get the password hash for the email or nickname 4. Compare the password hash with the password hash from the database

func (*Service) Logout added in v0.7.0

func (a *Service) Logout(c *fiber.Ctx) error

func (*Service) Register added in v0.6.2

func (a *Service) Register(c *fiber.Ctx) error

Register handles the creation of a new user

type SessionData added in v0.7.3

type SessionData struct {
	IP         string    `json:"ip"`
	UserAgent  string    `json:"user_agent"`
	DeviceUUID uuid.UUID `json:"device_uuid"`
	FirstSeen  time.Time `json:"first_seen"`
	LastSeen   time.Time `json:"last_seen"`
}

TODO: add saving logic (needed for bans etc)

type Validator

type Validator interface {
	Validate() (*member.Input, error)
}

Jump to

Keyboard shortcuts

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