gauth

package
v0.0.0-...-14b6000 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTH_FILE   = "./config/auth.json"
	ACCESS_FILE = "./config/access.json"

	DEFAULT_USER     = "root"
	DEFAULT_PASSWORD = "toor"
)

Variables

View Source
var (
	SAuthFile   = AUTH_FILE
	SAccessFile = ACCESS_FILE
)
View Source
var (
	MHash   tAuth   = make(tAuth, 0)
	MAccess tAccess = make(tAccess, 0)
)

Functions

func AddUser

func AddUser(sLogin string, sPassword string, stAccess TProfile) (err error)

Adding a user

func BlockUser

func BlockUser(sLogin string) (err error)

Blocking the user

func CheckUser

func CheckUser(sUser string, sPassword string) bool

User verification

func DeleteUser

func DeleteUser(sLogin string) (err error)

Deleting a user

func GenerateTicket

func GenerateTicket() string

Ticket generation

func GetTicket

func GetTicket(login string) (ticket string, err error)

Getting a ticket

func NewAuth

func NewAuth(stSecret *gtypes.TSecret) (sTicket string, err error)

Authorization verification and ticket issuance

func Shutdown

func Shutdown(ctx context.Context, c *closer.TCloser)

Shutting down the service

func Start

func Start()

Package initialization

func UnblockUser

func UnblockUser(sLogin string) (err error)

Unblocking the user

func UpdateProfile

func UpdateProfile(sLogin string, stAccess TProfile) (err error)

Updating a profile of a user

func UpdateUser

func UpdateUser(sLogin string, sPassword string, stAccess TProfile) (err error)

Updating a user

Types

type TProfile

type TProfile struct {
	Description string
	Status      TStatus
	Roles       []TRole
}

func CheckTicket

func CheckTicket(sTicket string) (sLogin string, stAccess TProfile, sNewTicket string, err error)

Verifying the authenticity of the ticket and obtaining access rights.

func GetProfile

func GetProfile(sUser string) (stProf TProfile, err error)

Get user's profile and access rights

func (TProfile) IsAllowed

func (t TProfile) IsAllowed(rules []TRole) bool

Chacking of authorization.

type TRole

type TRole int
const (
	SYSTEM   TRole = iota
	ADMIN          // All administrator rights
	MANAGER        // User management rights only
	ENGINEER       // Only the rights to control the engine and to force the launch of diagnostic processes.
	USER           // Limited rights of a regular user.
)

func (TRole) IsAdmin

func (t TRole) IsAdmin() bool

func (TRole) IsEngineer

func (t TRole) IsEngineer() bool

func (TRole) IsManager

func (t TRole) IsManager() bool

func (TRole) IsNotUser

func (t TRole) IsNotUser() bool

func (TRole) IsSystem

func (t TRole) IsSystem() bool

func (TRole) IsUser

func (t TRole) IsUser() bool

func (TRole) String

func (t TRole) String() string

type TStatus

type TStatus int
const (
	UNDEFINED TStatus = iota
	NEW
	ACTIVE
	BANED
)

func (TStatus) IsBad

func (t TStatus) IsBad() bool

func (TStatus) IsGood

func (t TStatus) IsGood() bool

func (TStatus) String

func (t TStatus) String() string

Jump to

Keyboard shortcuts

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