| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 | package modelsimport (	"time"	jwt "github.com/golang-jwt/jwt/v4")type NetworkID stringtype RsrcType stringtype RsrcID stringtype UserRole stringtype UserGroupID stringfunc (r RsrcType) String() string {	return string(r)}const (	HostRsrc           RsrcType = "hosts"	RelayRsrc          RsrcType = "relays"	RemoteAccessGwRsrc RsrcType = "remote_access_gw"	ExtClientsRsrc     RsrcType = "extclients"	InetGwRsrc         RsrcType = "inet_gw"	EgressGwRsrc       RsrcType = "egress"	NetworkRsrc        RsrcType = "networks"	EnrollmentKeysRsrc RsrcType = "enrollment_key"	UserRsrc           RsrcType = "users"	AclRsrc            RsrcType = "acl"	DnsRsrc            RsrcType = "dns"	FailOverRsrc       RsrcType = "fail_over")const (	AllHostRsrcID           RsrcID   = "all_host"	AllRelayRsrcID          RsrcID   = "all_relay"	AllRemoteAccessGwRsrcID RsrcID   = "all_remote_access_gw"	AllExtClientsRsrc       RsrcType = "all_extclients"	AllInetGwRsrcID         RsrcID   = "all_inet_gw"	AllEgressGwRsrcID       RsrcID   = "all_egress"	AllNetworkRsrcID        RsrcID   = "all_network"	AllEnrollmentKeysRsrcID RsrcID   = "all_enrollment_key"	AllUserRsrcID           RsrcID   = "all_user"	AllDnsRsrcID            RsrcID   = "all_dns"	AllFailOverRsrc         RsrcID   = "all_fail_over")// Pre-Defined User Rolesconst (	SuperAdminRole UserRole = "super_admin"	AdminRole      UserRole = "admin"	NetworkAdmin   UserRole = "network_admin"	NetworkUser    UserRole = "network_user")func (r UserRole) String() string {	return string(r)}func (g UserGroupID) String() string {	return string(g)}type RsrcPermissionScope struct {	Create    bool `json:"create"`	Read      bool `json:"read"`	Update    bool `json:"update"`	Delete    bool `json:"delete"`	VPNAccess bool `json:"vpn_access"`}type UserRolePermissionTemplate struct {	ID                  UserRole                                    `json:"id"`	Default             bool                                        `json:"default"`	DenyDashboardAccess bool                                        `json:"deny_dashboard_access"`	FullAccess          bool                                        `json:"full_access"`	IsNetworkRole       bool                                        `json:"network_role"`	NetworkLevelAccess  map[RsrcType]map[RsrcID]RsrcPermissionScope `json:"network_level_access"`	GlobalLevelAccess   map[RsrcType]map[RsrcID]RsrcPermissionScope `json:"global_level_access"`}type UserGroup struct {	ID           string                 `json:"id"`	NetworkRoles map[NetworkID]UserRole `json:"network_roles"`	MetaData     string                 `json:"meta_data"`}// User struct - struct for Userstype User struct {	UserName       string                 `json:"username" bson:"username" validate:"min=3,max=40,in_charset|email"`	Password       string                 `json:"password" bson:"password" validate:"required,min=5"`	IsAdmin        bool                   `json:"isadmin" bson:"isadmin"`	IsSuperAdmin   bool                   `json:"issuperadmin"`	RemoteGwIDs    map[string]struct{}    `json:"remote_gw_ids"`	UserGroup      UserGroupID            `json:"user_groups"`	PlatformRoleID UserRole               `json:"platform_role_id"`	NetworkRoles   map[NetworkID]UserRole `json:"network_roles"`	LastLoginTime  time.Time              `json:"last_login_time"`}// ReturnUser - return user structtype ReturnUser struct {	UserName       string                   `json:"username"`	IsAdmin        bool                     `json:"isadmin"`	IsSuperAdmin   bool                     `json:"issuperadmin"`	RemoteGwIDs    map[string]struct{}      `json:"remote_gw_ids"`	UserGroups     map[UserGroupID]struct{} `json:"user_groups"`	PlatformRoleID string                   `json:"platform_role_id"`	NetworkRoles   map[NetworkID]UserRole   `json:"network_roles"`	LastLoginTime  time.Time                `json:"last_login_time"`}// UserAuthParams - user auth params structtype UserAuthParams struct {	UserName string `json:"username"`	Password string `json:"password"`}// UserClaims - user claims structtype UserClaims struct {	IsAdmin      bool	IsSuperAdmin bool	UserName     string	jwt.RegisteredClaims}
 |