Documentation
¶
Index ¶
- Variables
- func GetGNameByNs(ns, name string) string
- func GetNsDevGName(ns string) string
- func GetNsOpGName(ns string) string
- type Cluster
- type Group
- func (g *Group) Byte() ([]byte, error)
- func (g *Group) GetGroup(gName string) (Group, error)
- func (g *Group) ListNsGroup(ns string) ([]Group, error)
- func (g *Group) ReadGName(gname string) (ns, name string)
- func (g *Group) UpdateGroupMember(gName string, addManagers, addMembers, removeManagers, removeMembers []string) (m.Row, error)
- func (g *Group) UpdateItems(gName string, items []string) error
- type GroupInf
- type Perm
- type User
- func (u *User) Byte() ([]byte, error)
- func (u *User) CheckUserExist(username string) (bool, error)
- func (u *User) GetUser(username string) (User, error)
- func (u *User) GetUserList(usernames []string) (map[string]User, error)
- func (u *User) SetUser(username, mobile string) error
- func (u *User) UpdateUser(username string, addGroup string, removeGroup string) (m.Row, error)
- func (u *User) UserRemoveUser(username string) ([]string, error)
- type UserInf
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // OP group name OP = "op" // DEV group name DEV = "dev" )
View Source
var ( // AuthBuck is the bucket id to save group and authorize data. AuthBuck = "authorize" // DefaultUser is a user. no use DefaultUser = "loda-defaultuser" // DefaultGName is the group name has all read permission of all node.. DefaultGName = "defaultgroup" // AdminGName is the group name has all permission of all node. AdminGName = "admingroup" )
Functions ¶
func GetGNameByNs ¶
GetGNameByNs reverse the ns and join the name. The purpose of reverse the ns is list the group by prefix, so that can list the group by ns. e.g: server1.product1.loda, op -> loda.product1.server1-op
func GetNsDevGName ¶
GetNsDevGName return dev group name of ns.
Types ¶
type Cluster ¶
type Cluster interface { // Get returns the value for the given key. View(bucket, key []byte) ([]byte, error) // RemoveKey removes the key from the bucket. RemoveKey(bucket, key []byte) error // Set sets the value for the given key, via distributed consensus. Update(bucket []byte, key []byte, value []byte) error // Batch update values for given keys in given buckets, via distributed consensus. Batch(rows []m.Row) error // ViewPrefix returns the value for the keys has the keyPrefix. ViewPrefix(bucket, keyPrefix []byte) (map[string][]byte, error) // Create a bucket via distributed consensus if not exist. CreateBucketIfNotExist(name []byte) error }
Cluster is the interface op must implement.
type Group ¶
type Group struct { GName string `json:"gname"` Managers []string `json:"managers"` Members []string `json:"members"` Items []string `json:"items"` // contains filtered or unexported fields }
Group is the infrmation one group has.
func (*Group) ListNsGroup ¶
ListNsGroup return group list of one ns.
type GroupInf ¶
type GroupInf interface { // ListGroup return the group list of under one ns. ListNsGroup(ns string) ([]Group, error) // GetGroup return the group by group name. GetGroup(gName string) (Group, error) // UpdateItems update the group permissions. UpdateItems(gName string, items []string) error // ReadGName return the ns and name of the group. ReadGName(gname string) (ns, name string) }
GroupInf is interface to manager group.
type Perm ¶
type Perm interface { // user interface UserInf // group interface GroupInf // DefaultGroupItems return the default permission of the ns. DefaultGroupItems(ns string) []string // DefaultGroupItems return the admin permission of the ns. AdminGroupItems(ns string) []string // Check return the query has the permission or not by ns/resource type/username/method. Check(username, ns, resourceType, method string) (bool, error) // InitGroup init default/admin group and default user. InitGroup(rootNode string) error // CreateGroup create a group. CreateGroup(gName string, managers, members, items []string) error // UpdateMember update group member and the user groups. UpdateMember(group string, managers, members []string) error // RemoveUser remove user from his all group. RemoveUser(username string) error // RemoveGroup remove the group. RemoveGroup(gName string) error }
Perm is interface to manager authorize.
type User ¶
type User struct { Username string `json:"username"` Mobile string `json:"mobile"` Groups []string `json:"groups"` // contains filtered or unexported fields }
User is the infomation one user has.
func (*User) CheckUserExist ¶
CheckUserExist return the username exist or not.
func (*User) GetUserList ¶
GetUserList return user list by username list.
func (*User) UpdateUser ¶
UpdateUser add or remove the user to or from group.
type UserInf ¶
type UserInf interface { // GetUser return user by username. GetUser(username string) (User, error) // GetUserList return a map[string]User, // key is username and value is User. GetUserList(usernames []string) (map[string]User, error) // SetUser create a user with username/mobile. SetUser(username, mobile string) error // CheckUserExist check the username exist or not. CheckUserExist(username string) (bool, error) }
UserInf is interface to manager user.
Click to show internal directories.
Click to hide internal directories.