Documentation ¶
Index ¶
Constants ¶
View Source
const ( ServiceAccessChecker = "resource:access-checker" ServiceChangeNotifier = "resource:change-notifier" ServiceManager = "resource:manager" )
View Source
const ( AccessReadMask = 0x01 << AccessRead AccessWriteMask = 0x01 << AccessWrite AccessCreateMask = 0x01 << AccessCreate AccessDeleteMask = 0x01 << AccessDelete AccessListMask = 0x01 << AccessList )
View Source
const AccessFullMask = AccessReadMask | AccessWriteMask | AccessCreateMask | AccessDeleteMask | AccessListMask
Variables ¶
View Source
var ( ErrForbidden = errors.New("forbidden") ErrUnknownResource = errors.New("resource not found") ErrDuplicate = errors.New("duplicate key") )
View Source
var AccessMaskMapping = map[string]int{ "r": AccessReadMask, "w": AccessWriteMask, "c": AccessCreateMask, "d": AccessDeleteMask, "l": AccessListMask, }
View Source
var AccessNames = []string{
"read",
"write",
"create",
"delete",
"list",
}
View Source
var AccessShortNames = []string{
"r",
"w",
"c",
"d",
"l",
}
Functions ¶
This section is empty.
Types ¶
type AccessChecker ¶
type AccessChecker interface { //CheckResourceAccess called when it is necessary to check access rights to Resource with given id; // objectID may be nil or contain id of Resource instance // accessKind defines action performing with resource // return should be ErrForbidden if access is forbidden or nil if granted; // in general may contain other value (e.g. ErrUnknownResource) CheckResourceAccess(ctx context.Context, id ID, objectID interface{}, accessKind AccessKind) (err error) // CheckResourceAccessByKey may be used for checking access by resource key; see CheckResourceAccess CheckResourceAccessByKey(ctx context.Context, key Key, objectID interface{}, accessKind AccessKind) (err error) }
AccessChecker defines access check implementation interface
type AccessKind ¶
type AccessKind int
const ( AccessRead AccessKind = iota AccessWrite AccessCreate AccessDelete AccessList )
type ChangeKind ¶
type ChangeKind int
const ( ChangeModified ChangeKind = iota ChangeCreated ChangeDeleted )
type ChangeNotifier ¶
type ChangeNotifier interface {
NotifyResourceChanged(id ID, objectID interface{}, kind ChangeKind)
}
ChangeNotifier may be used for notification of resource changes
type Key ¶
type Key string
Key may be used to uniquely identify resource by name; generally resource may have unique int id
Click to show internal directories.
Click to hide internal directories.