basic

package
v0.0.0-...-7662171 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthType = "basic"
)

Variables

View Source
var Errors map[int]string = map[int]string{
	10300000: "Security.OnChange: fail",

	10300100: "Security.Add: User `%v` is already exists",
	10300101: "Security.Add: Permission denied",
	10300102: "Security.Add: Permission check fail",

	10300200: "Security.Update: User `%v` does not exists",
	10300201: "Security.Update: Permission denied",
	10300202: "Security.Update: Permission check fail",

	10300300: "Security.Enable: User `%v` does not exists",
	10300301: "Security.Enable: Permission denied",
	10300302: "Security.Enable: Permission check fail",

	10300400: "Security.Disable: User `%v` does not exists",
	10300401: "Security.Disable: Permission denied",
	10300402: "Security.Disable: Permission check fail",

	10300500: "Security.Drop: User `%v` does not exists",
	10300501: "Security.Drop: Permission denied",
	10300502: "Security.Drop: Permission check fail",

	10300600: "StorageOnChangeFuncGenerator: fail generate json",
	10300601: "StorageOnChangeFuncGenerator: fail save data",
	10300700: "SecurityATRZ.StorageLoad: fail load data",
	10300701: "SecurityATRZ.StorageLoad: fail unmarshal data",

	10300800: "Security.Get: Permission denied",
	10300801: "Security.Get: Permission check fail",

	10300900: "Security.CheckAuthFunc: Unkown user `%v`",
	10300901: "Security.CheckAuthFunc: User is disabled `%v`",
	10300902: "Security.CheckAuthFunc: Auth user fail Unmarshal",
	10300903: "Security.CheckAuthFunc: Pwd check fail for user `%v`",
	10300904: "Security.CheckAuthFunc: Permission Impresonate fail",
	10300905: "Security.CheckAuthFunc: Permission Impresonate denied: request: `%v`, Service: `%v`",
	10300906: "Security.CheckAuthFunc: Request is NIL",
	10300907: "Security.CheckAuthFunc: Incorrect AuthType",

	10301000: "PasswordMarshal: Fail marshal PWD",
}

Errors codes and description

View Source
var WaitTimeout = time.Second * 5

Functions

func AddUseCluster

func AddUseCluster(eac *cluster.ExternalAbstractCluster, user cn.CapUser, us UserSend) (err *mft.Error)

func DisableUseCluster

func DisableUseCluster(eac *cluster.ExternalAbstractCluster, user cn.CapUser, name string) (err *mft.Error)

func DropUseCluster

func DropUseCluster(eac *cluster.ExternalAbstractCluster, user cn.CapUser, name string) (err *mft.Error)

func EnableUseCluster

func EnableUseCluster(eac *cluster.ExternalAbstractCluster, user cn.CapUser, name string) (err *mft.Error)

func GenerateError

func GenerateError(key int, a ...interface{}) *mft.Error

GenerateError -

func GenerateErrorE

func GenerateErrorE(key int, err error, a ...interface{}) *mft.Error

GenerateErrorE -

func GenerateErrorForClusterUser

func GenerateErrorForClusterUser(user cn.CapUser, key int, a ...interface{}) *mft.Error

GenerateError -

func GenerateErrorForClusterUserE

func GenerateErrorForClusterUserE(user cn.CapUser, key int, err error, a ...interface{}) *mft.Error

GenerateError -

func PasswordMarshal

func PasswordMarshal(pwd string) []byte

func Sha512

func Sha512(name string, pwd string) string

func StorageOnChangeFuncGenerator

func StorageOnChangeFuncGenerator(s storage.Storage, file string) func(sec *SecurityATCB) (err *mft.Error)

func UpdateUseCluster

func UpdateUseCluster(eac *cluster.ExternalAbstractCluster, user cn.CapUser, us UserSend) (err *mft.Error)

Types

type SecurityATCB

type SecurityATCB struct {
	Users map[string]*User `json:"users"`

	// OnChange event func (send self)
	OnChangeFunc func(s *SecurityATCB) (err *mft.Error) `json:"-"`

	// case nil then ignore
	CheckPermissionFunc func(ctx context.Context, user cn.CapUser, objectType string, action string, objectName string) (allowed bool, err *mft.Error) `json:"-"`
	// contains filtered or unexported fields
}

SecurityATCB - authentication basic

func StorageLoad

func StorageLoad(s storage.Storage, file string,
	checkPermissionFunc func(ctx context.Context, user cn.CapUser, objectType string, action string, objectName string) (allowed bool, err *mft.Error),
) (sec *SecurityATCB, err *mft.Error)

func (*SecurityATCB) Add

func (s *SecurityATCB) Add(ctx context.Context, user cn.CapUser, us UserSend) (err *mft.Error)

func (*SecurityATCB) AdditionalCallFuncInClusterFunc

func (s *SecurityATCB) AdditionalCallFuncInClusterFunc(ctx context.Context,
	cl cluster.Cluster, request *cluster.RequestBody) (responce *cluster.ResponceBody, ok bool)

func (*SecurityATCB) CheckAuthFunc

func (s *SecurityATCB) CheckAuthFunc(ctx context.Context, serviceRequest *cluster.ServiceRequest,
) (ok bool, failResponce cluster.ResponceBody)

func (*SecurityATCB) CheckPermissionForInternal

func (s *SecurityATCB) CheckPermissionForInternal(ctx context.Context, user cn.CapUser, objectType string, action string, objectName string) (allowed bool, err *mft.Error)

func (*SecurityATCB) Disable

func (s *SecurityATCB) Disable(ctx context.Context, user cn.CapUser, name string) (err *mft.Error)

func (*SecurityATCB) Drop

func (s *SecurityATCB) Drop(ctx context.Context, user cn.CapUser, name string) (err *mft.Error)

func (*SecurityATCB) Enable

func (s *SecurityATCB) Enable(ctx context.Context, user cn.CapUser, name string) (err *mft.Error)

func (*SecurityATCB) Get

func (s *SecurityATCB) Get(ctx context.Context, user cn.CapUser) (users []UserCut, err *mft.Error)

func (*SecurityATCB) OnChange

func (s *SecurityATCB) OnChange() (err *mft.Error)

func (*SecurityATCB) Update

func (s *SecurityATCB) Update(ctx context.Context, user cn.CapUser, us UserSend) (err *mft.Error)

type User

type User struct {
	Name     string `json:"name"`
	IsEnable bool   `json:"is_enable"`
	PwdHash  string `json:"pwd_hash"`
}

func (*User) UserCut

func (u *User) UserCut() UserCut

type UserCut

type UserCut struct {
	Name     string `json:"name"`
	IsEnable bool   `json:"is_enable"`
}

func GetUseCluster

func GetUseCluster(eac *cluster.ExternalAbstractCluster, user cn.CapUser) (users []UserCut, err *mft.Error)

type UserSend

type UserSend struct {
	Name string `json:"name"`
	Pwd  string `json:"pwd"`
}

Jump to

Keyboard shortcuts

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