login

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SelectFailedInNWithErrorE  = "pgxscan.Select unexpectedly failed in %s, error : %v"
	FunctionNReturnedNoResults = "%s returned no results "
	UserDoesNotExist           = "User %s does not exist"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type F5Authenticator

type F5Authenticator interface {
	gohttp.Authentication
	GetJwtInfoHandler() http.HandlerFunc
}

func NewLoginService

func NewLoginService(db database.DB, store Storage, jwtCheck gohttp.JwtChecker) F5Authenticator

NewLoginService Function to create an instance of Login Service Authenticator

type JwtInfo

type JwtInfo struct {
	Authenticated bool   `json:"authenticated"`
	Method        string `json:"method"`
	Message       string `json:"message"`
	Token         string `json:"token"`
	Login         string `json:"login"`
	Email         string `json:"email"`
	UserId        int    `json:"user_id"`
}

type PGX

type PGX struct {
	Conn *pgxpool.Pool
	// contains filtered or unexported fields
}

func (*PGX) CreateOrUpdateAdminUserOrPanic added in v0.1.5

func (db *PGX) CreateOrUpdateAdminUserOrPanic()

CreateOrUpdateAdminUserOrPanic is a function to create or update the admin user in the database

func (*PGX) Exist

func (db *PGX) Exist(login string) bool

func (*PGX) Get

func (db *PGX) Get(login string) (*User, error)

func (*PGX) IsAdmin

func (db *PGX) IsAdmin(login string) bool

func (*PGX) IsLocked

func (db *PGX) IsLocked(login string) bool

func (*PGX) IsUserActive

func (db *PGX) IsUserActive(login string) bool

type Service

type Service struct {
	Log        golog.MyLogger
	DbConn     database.DB
	Store      Storage
	JwtChecker gohttp.JwtChecker
}

func (*Service) AuthenticateUser

func (s *Service) AuthenticateUser(user, passwordHash string) bool

func (*Service) GetJwtInfoHandler

func (s *Service) GetJwtInfoHandler() http.HandlerFunc

func (*Service) GetUserInfoFromLogin

func (s *Service) GetUserInfoFromLogin(login string) (*gohttp.UserInfo, error)

type Storage

type Storage interface {
	//CreateOrUpdateAdminUserOrPanic creates or updates the admin user in the store
	CreateOrUpdateAdminUserOrPanic()
	// Get returns the user with the specified user login.
	Get(login string) (*User, error)
	// Exist returns true only if a user with the specified login exists in store.
	Exist(login string) bool
	// IsUserActive returns true if the user with the specified login has the is_active attribute set to true
	IsUserActive(login string) bool
	// IsAdmin returns true if the user with the specified login has the is_admin attribute set to true
	IsAdmin(login string) bool
	// IsLocked returns true if the user with the specified login has the is_locked attribute set to true
	IsLocked(login string) bool
}

func GetStorageInstanceOrPanic

func GetStorageInstanceOrPanic(dbDriver string, db database.DB, l golog.MyLogger) Storage

func NewPgxDB

func NewPgxDB(db database.DB, log golog.MyLogger) (Storage, error)

NewPgxDB will instantiate a new storage of type postgres and ensure schema exist

type User

type User struct {
	Id                   int32      `json:"id"`
	Name                 string     `json:"name"`
	Email                string     `json:"email"`
	Username             string     `json:"username"`
	PasswordHash         string     `json:"password_hash"`
	ExternalId           *int32     `json:"external_id,omitempty"`
	IsLocked             bool       `json:"is_locked"`
	IsAdmin              bool       `json:"is_admin"`
	CreateTime           time.Time  `json:"create_time"`
	Creator              int32      `json:"creator"`
	LastModificationTime *time.Time `json:"last_modification_time,omitempty"`
	LastModificationUser *int32     `json:"last_modification_user,omitempty"`
	IsActive             bool       `json:"is_active"`
	InactivationTime     *time.Time `json:"inactivation_time,omitempty"`
	InactivationReason   *string    `json:"inactivation_reason,omitempty"`
	Comment              *string    `json:"comment,omitempty"`
	BadPasswordCount     int32      `json:"bad_password_count"`
}

Jump to

Keyboard shortcuts

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