vsec

package
v0.0.0-...-3b984fc Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthLevel

type AuthLevel int

AuthLevel - authorization of an user

const (
	//Super - super user
	Super AuthLevel = iota

	//Admin - application admin
	Admin

	//Normal - normal user
	Normal

	//Monitor - readonly user
	Monitor

	//Public - no authentication required
	Public
)

func (AuthLevel) String

func (a AuthLevel) String() string

type Group

type Group struct {
	OID   bson.ObjectId `json:"_id" bson:"_id"`
	Name  string        `json:"name" bson:"name"`
	Users []string      `json:"users" bson:"users"`
}

Group - group of users

type User

type User struct {
	OID         bson.ObjectId `json:"_id" bson:"_id,omitempty"`
	ID          string        `json:"id" bson:"id"`
	Email       string        `json:"email" bson:"email"`
	Auth        AuthLevel     `json:"auth" bson:"auth"`
	FirstName   string        `json:"firstName" bson:"firstName"`
	LastName    string        `json:"lastName" bson:"lastName"`
	Title       string        `json:"title" bson:"title"`
	FullName    string        `json:"fullName" bson:"fullName"`
	State       UserState     `json:"state" bson:"state"`
	VerID       string        `json:"verID" bson:"verID"`
	PwdExpiry   time.Time     `json:"pwdExpiry" bson:"pwdExpiry"`
	Created     time.Time     `json:"created" bson:"created"`
	Modified    time.Time     `json:"modified" bson:"modified"`
	VerfiedDate time.Time     `json:"verified" bson:"verified"`
	Props       bson.M        `json:"props" bson:"props"`
}

User - represents an user

type UserState

type UserState string

UserState - state of the user account

var Active UserState = "active"

Active - user is active

var Disabled UserState = "disabled"

Disabled - user account is disabled by an admin

var Flagged UserState = "flagged"

Flagged - user account is flagged by a user

var Verfied UserState = "verified"

Verfied - user account is verified by the user

type UserStorage

type UserStorage interface {
	//CreateUser - creates user in database
	CreateUser(user *User) (err error)

	//UpdateUser - updates user in database
	UpdateUser(user *User) (err error)

	//DeleteUser - deletes user with given user ID
	DeleteUser(userID string) (err error)

	//GetUser - gets details of the user corresponding to ID
	GetUser(userID string) (user *User, err error)

	//GetAllUsers - gets all users based on offset and limit
	GetUsers(offset int,
		limit int,
		filter *vcmn.Filter) (users []*User, err error)

	//GetCount - gives the number of user selected by given filter
	GetCount(filter *vcmn.Filter) (count int, err error)

	//GetUsersWithCount - gives a list of users paged with total count
	GetUsersWithCount(offset int,
		limit int,
		filter *vcmn.Filter) (total int, users []*User, err error)

	//ResetPassword - sets password of a unauthenticated user
	ResetPassword(userID, oldPwd, newPwd string) (err error)

	//SetPassword - sets password of a already authenticated user, old password
	//is not required
	SetPassword(userID, newPwd string) (err error)

	//ValidateUser - validates user ID and password
	ValidateUser(userID, password string) (err error)

	//GetUserAuthLevel - gets user authorization level
	GetUserAuthLevel(userID string) (level AuthLevel, err error)

	//CreateSuperUser - creates the first super user for the application
	CreateSuperUser(user *User, password string) (err error)

	//SetUserState - sets state of an user account
	SetUserState(userID string, state UserState) (err error)

	//VerifyUser - sets state of an user account to verified based on userID
	//and verification ID
	VerifyUser(userID, verID string) (err error)

	//CreateIndices - creates mongoDB indeces for tables used for user management
	CreateIndices() (err error)

	//CleanData - cleans user management related data from database
	CleanData() (err error)

	//UpdateProfile - updates user details - this should be used when user
	//logged in is updating own user account
	UpdateProfile(user *User) (err error)
}

UserStorage - interface representing strategy to store and manage user information

Jump to

Keyboard shortcuts

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