admin

package
v0.0.0-...-08f68e1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongPassword  = errors.New("wrong password")
	ErrWrongSecretKey = errors.New("wrong secret key")
)
View Source
var ErrAdminUserNotFound = errors.New("admin user does not exist")
View Source
var ErrDuplicateAdminUser = errors.New("admin user with the same email exists")
View Source
var ErrDuplicateTunnelUser = errors.New("tunnel user with the same email exists")
View Source
var ErrInvalidUserSession = errors.New("invalid user session")
View Source
var ErrMultipleSuperuserError = errors.New("you cannot create more than one superuser")
View Source
var ErrTunnelUserNotFound = errors.New("tunnel user does not exist")
View Source
var ErrWrongEmailOrPassword = errors.New("wrong email or password")

Functions

This section is empty.

Types

type AdminUser

type AdminUser struct {
	gorm.Model

	Email        string `gorm:"index,unique"`
	PasswordHash string `gorm:"unique" json:"-"`
	SuperUser    bool

	Session Session
}

func (*AdminUser) CheckPassword

func (a *AdminUser) CheckPassword(rawPassword string) error

func (*AdminUser) SetPassword

func (a *AdminUser) SetPassword(rawPassword string) error

type Session

type Session struct {
	gorm.Model

	Token       string `gorm:"index, unique"`
	AdminUserId uint
}

func (*Session) GenerateSessionToken

func (s *Session) GenerateSessionToken() error

type TunnelUser

type TunnelUser struct {
	gorm.Model

	Email        string  `gorm:"index,unique"`
	SecretKey    *string `gorm:"index,unique" json:"-"`
	Active       bool
	LastActiveAt *time.Time
}

func (*TunnelUser) RotateSecretKey

func (t *TunnelUser) RotateSecretKey() string

type UserService

type UserService struct {
	DB *gorm.DB
}

func NewUserService

func NewUserService(store *gorm.DB) *UserService

func (*UserService) CanCreateSuperUser

func (u *UserService) CanCreateSuperUser(ctx context.Context) error

func (*UserService) CreateAdminUser

func (u *UserService) CreateAdminUser(ctx context.Context, email, password string) (*AdminUser, error)

func (*UserService) CreateSuperUser

func (u *UserService) CreateSuperUser(ctx context.Context, email, password string) (*AdminUser, error)

func (*UserService) CreateTunnelUser

func (u *UserService) CreateTunnelUser(ctx context.Context, email string) (*TunnelUser, error)

func (*UserService) CreateUser

func (u *UserService) CreateUser(ctx context.Context, email, password string, superUser bool) (*AdminUser, error)

func (*UserService) DeleteTunnelUser

func (u *UserService) DeleteTunnelUser(ctx context.Context, id uint) error

func (*UserService) GetTunnelUserBySecret

func (u *UserService) GetTunnelUserBySecret(ctx context.Context, secretKey string) (*TunnelUser, error)

func (*UserService) GetUserConnectionStatus

func (u *UserService) GetUserConnectionStatus(ctx context.Context) ([]TunnelUser, error)

func (*UserService) ListTunnelUsers

func (u *UserService) ListTunnelUsers(ctx context.Context) ([]TunnelUser, error)

func (*UserService) Login

func (u *UserService) Login(ctx context.Context, email, password string) (string, error)

func (*UserService) Logout

func (u *UserService) Logout(ctx context.Context, sessionToken string) error

func (*UserService) RotateTunnelUserSecretKey

func (u *UserService) RotateTunnelUserSecretKey(ctx context.Context, email string) (*TunnelUser, error)

func (*UserService) SetActiveConnection

func (u *UserService) SetActiveConnection(ctx context.Context, tunnelUser *TunnelUser) error

func (*UserService) SetInactiveConnectionStatusForUsers

func (u *UserService) SetInactiveConnectionStatusForUsers(ctc context.Context, userIdentifiers ...string) error

func (*UserService) ValidateSession

func (u *UserService) ValidateSession(ctx context.Context, sessionToken string) (*AdminUser, error)

Jump to

Keyboard shortcuts

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