permission

package
v0.0.0-...-0cf49f2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2015 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CtxGlobal          = contextType("global")
	CtxApp             = contextType("app")
	CtxTeam            = contextType("team")
	CtxPool            = contextType("pool")
	CtxIaaS            = contextType("iaas")
	CtxServiceInstance = contextType("service-instance")
)
View Source
var (
	PermAll                         = PermissionRegistry.get("")
	PermApp                         = PermissionRegistry.get("app")
	PermAppCreate                   = PermissionRegistry.get("app.create")
	PermAppDelete                   = PermissionRegistry.get("app.delete")
	PermAppDeploy                   = PermissionRegistry.get("app.deploy")
	PermAppRead                     = PermissionRegistry.get("app.read")
	PermAppUpdate                   = PermissionRegistry.get("app.update")
	PermAppUpdateEnv                = PermissionRegistry.get("app.update.env")
	PermAppUpdateEnvSet             = PermissionRegistry.get("app.update.env.set")
	PermAppUpdateEnvUnset           = PermissionRegistry.get("app.update.env.unset")
	PermAppUpdateRestart            = PermissionRegistry.get("app.update.restart")
	PermIaas                        = PermissionRegistry.get("iaas")
	PermIaasRead                    = PermissionRegistry.get("iaas.read")
	PermNode                        = PermissionRegistry.get("node")
	PermNodeCreate                  = PermissionRegistry.get("node.create")
	PermNodeDelete                  = PermissionRegistry.get("node.delete")
	PermNodeRead                    = PermissionRegistry.get("node.read")
	PermNodeUpdate                  = PermissionRegistry.get("node.update")
	PermServiceInstance             = PermissionRegistry.get("service-instance")
	PermServiceInstanceCreate       = PermissionRegistry.get("service-instance.create")
	PermServiceInstanceDelete       = PermissionRegistry.get("service-instance.delete")
	PermServiceInstanceRead         = PermissionRegistry.get("service-instance.read")
	PermServiceInstanceUpdate       = PermissionRegistry.get("service-instance.update")
	PermServiceInstanceUpdateBind   = PermissionRegistry.get("service-instance.update.bind")
	PermServiceInstanceUpdateGrant  = PermissionRegistry.get("service-instance.update.grant")
	PermServiceInstanceUpdateRevoke = PermissionRegistry.get("service-instance.update.revoke")
	PermServiceInstanceUpdateUnbind = PermissionRegistry.get("service-instance.update.unbind")
	PermTeam                        = PermissionRegistry.get("team")
	PermTeamCreate                  = PermissionRegistry.get("team.create")
	PermTeamDelete                  = PermissionRegistry.get("team.delete")
	PermTeamUpdate                  = PermissionRegistry.get("team.update")
	PermTeamUpdateAddMember         = PermissionRegistry.get("team.update.add-member")
	PermTeamUpdateRemoveMember      = PermissionRegistry.get("team.update.remove-member")
	PermUser                        = PermissionRegistry.get("user")
	PermUserCreate                  = PermissionRegistry.get("user.create")
	PermUserDelete                  = PermissionRegistry.get("user.delete")
	PermUserList                    = PermissionRegistry.get("user.list")
	PermUserUpdate                  = PermissionRegistry.get("user.update")
)
View Source
var (
	ErrRoleNotFound      = errors.New("role not found")
	ErrRoleAlreadyExists = errors.New("role already exists")
)
View Source
var PermissionRegistry = (&registry{}).addWithCtx(
	"app", []contextType{CtxApp, CtxTeam, CtxPool},
).addWithCtx(
	"app.create", []contextType{CtxTeam, CtxPool},
).add(
	"app.update.env.set",
	"app.update.env.unset",
	"app.update.restart",
	"app.deploy",
	"app.read",
	"app.delete",
).addWithCtx(
	"node", []contextType{CtxPool},
).add(
	"node.create",
	"node.read",
	"node.update",
	"node.delete",
).addWithCtx(
	"iaas.read", []contextType{CtxIaaS},
).addWithCtx(
	"team", []contextType{CtxTeam},
).addWithCtx(
	"team.create", []contextType{},
).add(
	"team.delete",
	"team.update.add-member",
	"team.update.remove-member",
).add(
	"user.create",
	"user.delete",
	"user.list",
	"user.update",
).addWithCtx(
	"service-instance", []contextType{CtxServiceInstance, CtxTeam},
).addWithCtx(
	"service-instance.create", []contextType{},
).add(
	"service-instance.read",
	"service-instance.delete",
	"service-instance.update.bind",
	"service-instance.update.unbind",
	"service-instance.update.grant",
	"service-instance.update.revoke",
)

Functions

func Check

func Check(token Token, scheme *permissionScheme, contexts ...Context) bool

func DestroyRole

func DestroyRole(name string) error

Types

type Context

type Context struct {
	CtxType contextType
	Value   interface{}
}

type Permission

type Permission struct {
	Scheme  *permissionScheme
	Context Context
}

type PermissionSchemeList

type PermissionSchemeList []*permissionScheme

func (PermissionSchemeList) Len

func (l PermissionSchemeList) Len() int

func (PermissionSchemeList) Less

func (l PermissionSchemeList) Less(i, j int) bool

func (PermissionSchemeList) Swap

func (l PermissionSchemeList) Swap(i, j int)

type Role

type Role struct {
	Name        string      `bson:"_id" json:"name"`
	ContextType contextType `json:"context"`
	SchemeNames []string    `json:"scheme_names,omitempty"`
}

func FindRole

func FindRole(name string) (Role, error)

func ListRoles

func ListRoles() ([]Role, error)

func NewRole

func NewRole(name string, ctx string) (Role, error)

func (*Role) AddPermissions

func (r *Role) AddPermissions(permNames ...string) error

func (*Role) PermisionsFor

func (r *Role) PermisionsFor(contextValue string) []Permission

func (*Role) RemovePermissions

func (r *Role) RemovePermissions(permNames ...string) error

type Token

type Token interface {
	Permissions() ([]Permission, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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