auth

package
v0.0.0-...-72e33f6 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUserPassword

func CheckUserPassword(hash, password string) error

func CreateGroup

func CreateGroup(ctx context.Context, arg CreateGroupParams) (int64, error)

func CreateUser

func CreateUser(ctx context.Context, cfg system.Config, arg CreateUserParams) (int64, error)

func CreateUserSession

func CreateUserSession(ctx context.Context, arg CreateUserSessionParams) (string, error)

func DeleteGroup

func DeleteGroup(ctx context.Context, id int64) error

func DeleteOtherUserSessions

func DeleteOtherUserSessions(ctx context.Context, userID int64, currentSessionID int64) error

func DeleteUser

func DeleteUser(ctx context.Context, id int64) error

func DeleteUserSession

func DeleteUserSession(ctx context.Context, userID int64, sessionID int64) error

func DeleteUserSessionBySession

func DeleteUserSessionBySession(ctx context.Context, session string) error

func GetUser

func GetUser(ctx context.Context) (repo.User, error)

func GetUserByUsernameOrEmail

func GetUserByUsernameOrEmail(ctx context.Context, usernameOrEmail string) (repo.User, error)

func GetUserSessionForContext

func GetUserSessionForContext(ctx context.Context, session string) (repo.AuthGetUserSessionForContextRow, error)

func Init

func Init(_app App)

func ListUserSessions

func ListUserSessions(ctx context.Context) ([]repo.UserSession, error)

func TouchUserSession

func TouchUserSession(ctx context.Context, arg TouchUserSessionParams) error

func UpdateGroup

func UpdateGroup(ctx context.Context, arg UpdateGroupParams) error

func UpdateGroupDisable

func UpdateGroupDisable(ctx context.Context, userID int64, disable bool) error

func UpdateUser

func UpdateUser(ctx context.Context, arg UpdateUserParams) error

func UpdateUserAdmin

func UpdateUserAdmin(ctx context.Context, id int64, admin bool) error

func UpdateUserDisabled

func UpdateUserDisabled(ctx context.Context, id int64, disable bool) error

func UpdateUserPassword

func UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func UpdateUserUsername

func UpdateUserUsername(ctx context.Context, userID int64, newUsername string) error

func WithSession

func WithSession(ctx context.Context, session Session) context.Context

Types

type App

type App struct {
	DB                   sqlite.DB
	Hub                  *bus.Hub
	TouchSessionThrottle TouchSessionThrottle
}

type CreateGroupParams

type CreateGroupParams struct {
	Name        string
	Description string
}

type CreateUserParams

type CreateUserParams struct {
	Email    string
	Username string
	Password string
	Admin    bool
	Disabled bool
}

type CreateUserSessionParams

type CreateUserSessionParams struct {
	UserAgent       string
	IP              string
	UserID          int64
	RememberMe      bool
	PreviousSession string
}

type Session

type Session struct {
	SessionID int64
	UserID    int64
	Username  string
	Admin     bool
	Disabled  bool
}

func UseSession

func UseSession(ctx context.Context) (Session, bool)

type TouchSessionThrottle

type TouchSessionThrottle struct {
	*core.LockStore[int64]
	Duration time.Duration
}

func NewTouchSessionThrottle

func NewTouchSessionThrottle() TouchSessionThrottle

type TouchUserSessionParams

type TouchUserSessionParams struct {
	CurrentSessionID int64
	LastUsedAt       time.Time
	LastIP           string
	IP               string
}

type UpdateGroupParams

type UpdateGroupParams struct {
	ID          int64
	Name        string
	Description string
}

type UpdateUserParams

type UpdateUserParams struct {
	ID       int64
	Email    string
	Username string
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	UserID           int64
	OldPasswordSkip  bool
	OldPassword      string
	NewPassword      string
	CurrentSessionID int64
}

Jump to

Keyboard shortcuts

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