Documentation
¶
Index ¶
- Constants
- Variables
- func AnyOfTagsAuthorizer(tags []access.Tag, perms access.Permissions) *anyOfTagsAuthorizer
- func CheckImplicitPerms(ctx *context.T, call rpc.ServerCall, id wire.Id, allowedTags []access.Tag) (access.Permissions, error)
- func DecodeIdKeyPart(idKeyPart string) (wire.Id, error)
- func EncodeIdKeyPart(id wire.Id) string
- func ErrorToExists(err error) (bool, error)
- func ExistAuthStep(ctx *context.T, call rpc.ServerCall, name string, ...) error
- func FirstKeyPart(key string) string
- func GetDataWithAuth(ctx *context.T, call rpc.ServerCall, at Permser, tags []access.Tag, ...) (access.Permissions, error)
- func GetDataWithExistAuthStep(ctx *context.T, call rpc.ServerCall, name string, ...) error
- func GetPermsWithAuth(ctx *context.T, call rpc.ServerCall, at Permser, tags []access.Tag, ...) (access.Permissions, error)
- func GetPermsWithExistAndParentResolveAuth(ctx *context.T, call rpc.ServerCall, at Permser, st store.StoreReader) (access.Permissions, error)
- func IsRowKey(key string) bool
- func JoinBatchHandle(batchType BatchType, batchId uint64) wire.BatchHandle
- func JoinKeyParts(parts ...string) string
- func NewErrPermsDisallowedTags(ctx *context.T, disallowed []string, allowed []string) error
- func NewErrPermsEmpty(ctx *context.T) error
- func NewErrPermsNoAdmin(ctx *context.T) error
- func ParseCollectionPermsKey(key string) (collection wire.Id, err error)
- func ParseRowKey(key string) (collection wire.Id, row string, err error)
- func ScanPrefixArgs(stKeyPrefix, prefix string) ([]byte, []byte)
- func ScanRangeArgs(stKeyPrefix, start, limit string) ([]byte, []byte)
- func SplitKeyParts(key string) []string
- func SplitNKeyParts(key string, n int) []string
- func StripFirstKeyPartOrDie(key string) string
- func TagAuthorizer(tag access.Tag, perms access.Permissions) *anyOfTagsAuthorizer
- func ValidatePerms(ctx *context.T, perms access.Permissions, allowTags []access.Tag) error
- type BatchType
- type Permser
- type PermserData
Constants ¶
const ( AppPrefix = "a" CollectionPermsPrefix = "c" DatabasePrefix = "d" DbGCPrefix = "g" DbInfoPrefix = "i" LogPrefix = "l" LogMarkerPrefix = "m" VClockPrefix = "q" RowPrefix = "r" ServicePrefix = "s" VersionPrefix = "v" SyncPrefix = "y" // KeyPartSep is a separator for parts of storage engine keys, e.g. separating // collection id from row key. KeyPartSep = "\xfe" // PrefixRangeLimitSuffix is a key suffix that indicates the end of a prefix // range. Must be greater than any character allowed in client-specified keys. PrefixRangeLimitSuffix = "\xff" // IdPartSep is a separator and terminator for id encoding in keys. NUL was // chosen to make ids encoded as <blessing><sep><name><sep> sorted, first by // blessing, then by name. IdPartSep = "\x00" // AppDir is the filesystem directory that holds all app databases. AppDir = "apps" // DbDir is the filesystem directory that holds all databases for an app. DbDir = "dbs" )
Constants related to storage engine keys. Note, these are persisted and therefore must not be modified.
const ( // The pool.ntp.org project is a big virtual cluster of timeservers providing // reliable easy to use NTP service for millions of clients. // For more information, see: http://www.pool.ntp.org/en/ NtpDefaultHost = "pool.ntp.org:123" )
Other constants.
const ( // Object name component for Syncbase-to-Syncbase (sync) RPCs. // Sync object names have the form: // <syncbase>/%%sync/... SyncbaseSuffix = "%%sync" )
Constants related to object names.
Variables ¶
var ( ErrPermsEmpty = verror.Register("v.io/x/ref/services/syncbase/common.PermsEmpty", verror.NoRetry, "{1:}{2:} permissions cannot be empty") ErrPermsNoAdmin = verror.Register("v.io/x/ref/services/syncbase/common.PermsNoAdmin", verror.NoRetry, "{1:}{2:} permissions must include at least one admin") ErrPermsDisallowedTags = verror.Register("v.io/x/ref/services/syncbase/common.PermsDisallowedTags", verror.NoRetry, "{1:}{2:} permissions tags {3} are not allowed; only {4} are allowed") )
Functions ¶
func AnyOfTagsAuthorizer ¶
func AnyOfTagsAuthorizer(tags []access.Tag, perms access.Permissions) *anyOfTagsAuthorizer
AnyOfTagsAuthorizer provides an authorizer that allows blessings matching any pattern in perms corresponding to any of the provided tags.
func CheckImplicitPerms ¶
func CheckImplicitPerms(ctx *context.T, call rpc.ServerCall, id wire.Id, allowedTags []access.Tag) (access.Permissions, error)
CheckImplicitPerms performs an authorization check against the implicit permissions derived from the blessing pattern in the Id. It returns the generated implicit perms or an authorization error. TODO(ivanpi): Change to check against the specific blessing used for signing instead of any blessing in call.Security().
func DecodeIdKeyPart ¶
DecodeIdKeyPart is the inverse of EncodeIdKeyPart.
func EncodeIdKeyPart ¶
EncodeIdKeyPart encodes an id for embedding in a store key. No escaping is necessary since valid ids are guaranteed not to contain reserved key bytes such as '\xfe'. Ids are encoded as "<blessing>\x00<name>\x00" to preserve the natural sort order (first by blessing, then by name) even when embedded in store keys.
func ErrorToExists ¶
ErrorToExists converts the error returned from GetDataWithExistAuth into the Exists RPC result, suppressing ErrNoExist.
func ExistAuthStep ¶
func ExistAuthStep(ctx *context.T, call rpc.ServerCall, name string, parentPerms access.Permissions, v PermserData, getErr error) error
ExistAuthStep is a helper intended for use in GetDataWithExistAuth implementations. It assumes Resolve access up to and including the object's grandparent. Taking into account the error from retrieving the object's metadata, it returns ErrNoExistOrNoAccess, ErrNoExist or other errors when appropriate; if the caller is not authorized for exist access, ErrNoExistOrNoAccess is always returned.
func FirstKeyPart ¶
FirstKeyPart returns the first part of 'key', typically a key prefix defined in constants.go.
func GetDataWithAuth ¶
func GetDataWithAuth(ctx *context.T, call rpc.ServerCall, at Permser, tags []access.Tag, st store.StoreReader, v PermserData) (access.Permissions, error)
GetDataWithAuth is equivalent to GetPermsWithAuth, in addition populating the loaded PermserData into v.
func GetDataWithExistAuthStep ¶
func GetDataWithExistAuthStep(ctx *context.T, call rpc.ServerCall, name string, parentPerms access.Permissions, st store.StoreReader, k string, v PermserData) error
GetDataWithExistAuthStep is a helper intended for use in GetDataWithExistAuth implementations. It assumes Resolve access up to and including the object's grandparent. It loads the object's metadata from the store into v, returning ErrNoExistOrNoAccess, ErrNoExist or other errors when appropriate; if the caller is not authorized for exist access, ErrNoExistOrNoAccess is always returned. If a nil StoreReader is passed in, the object is assumed to not exist.
func GetPermsWithAuth ¶
func GetPermsWithAuth(ctx *context.T, call rpc.ServerCall, at Permser, tags []access.Tag, st store.StoreReader) (access.Permissions, error)
GetPermsWithAuth returns a nil error only if the client has exist and parent resolve access (see GetPermsWithExistAndParentResolveAuth) as well as at least one of the specified tags on the object itself.
func GetPermsWithExistAndParentResolveAuth ¶
func GetPermsWithExistAndParentResolveAuth(ctx *context.T, call rpc.ServerCall, at Permser, st store.StoreReader) (access.Permissions, error)
GetPermsWithExistAndParentResolveAuth returns a nil error only if the object exists, the client is authorized to know it and has resolve access on all objects up to and including this object's parent.
func JoinBatchHandle ¶
func JoinBatchHandle(batchType BatchType, batchId uint64) wire.BatchHandle
JoinBatchHandle encodes batch type and id into a BatchHandle.
func JoinKeyParts ¶
JoinKeyParts builds keys for accessing data in the storage engine.
func NewErrPermsDisallowedTags ¶
NewErrPermsDisallowedTags returns an error with the ErrPermsDisallowedTags ID.
func NewErrPermsEmpty ¶
NewErrPermsEmpty returns an error with the ErrPermsEmpty ID.
func NewErrPermsNoAdmin ¶
NewErrPermsNoAdmin returns an error with the ErrPermsNoAdmin ID.
func ParseCollectionPermsKey ¶
ParseCollectionPermsKey extracts the collection id from the given storage engine key for a collection perms entry. Returns an error if the given key is not a storage engine key for a collection perms entry.
func ParseRowKey ¶
ParseRowKey extracts collection and row parts from the given storage engine key for a data row. Returns an error if the given key is not a storage engine key for a data row.
func ScanPrefixArgs ¶
ScanPrefixArgs returns args for sn.Scan() for the specified prefix.
func ScanRangeArgs ¶
ScanRangeArgs returns args for sn.Scan() for the specified range. If limit is "", all rows with keys >= start are included.
func SplitKeyParts ¶
SplitKeyParts is the inverse of JoinKeyParts. Clients are generally encouraged to use SplitNKeyParts.
func SplitNKeyParts ¶
SplitNKeyParts is to SplitKeyParts as strings.SplitN is to strings.Split.
func StripFirstKeyPartOrDie ¶
StripFirstKeyPartOrDie strips off the first part of the given key. Typically used to strip off the key prefixes defined in constants.go. Panics if the input string has fewer than two parts.
func TagAuthorizer ¶
func TagAuthorizer(tag access.Tag, perms access.Permissions) *anyOfTagsAuthorizer
TagAuthorizer provides an authorizer that allows blessings matching any pattern in perms corresponding to the provided tag.
func ValidatePerms ¶
ValidatePerms does basic sanity checking on the provided perms: - Perms can contain only tags in the provided whitelist. - At least one admin must be included to avoid permanently losing access.
Types ¶
type BatchType ¶
type BatchType byte
const ( BatchTypeSn BatchType = 's' // snapshot BatchTypeTx = 't' // transaction )
func SplitBatchHandle ¶
func SplitBatchHandle(bh wire.BatchHandle) (BatchType, uint64, error)
SplitBatchHandle is the inverse of JoinBatchHandle.
type Permser ¶
type Permser interface { // GetDataWithExistAuth must return a nil error only if the object exists and // the caller is authorized to know it (Resolve access up to the parent and // any access tag on self, or Resolve access up to grandparent and Read or // Write on parent). Otherwise, the returned error must not leak existence // data (ErrNoExistOrNoAccess must be returned instead of more specific // errors such as ErrNoExist if the caller is not authorized to know about // an object's existence). // If the error is nil, PermserData must be populated with object metadata // loaded from the store and the method must return perms of the object's // parent and the object itself. // A typical implementation calls GetPermsWithExistAndParentResolveAuth on // the object's parent, followed by GetDataWithExistAuthStep. GetDataWithExistAuth(ctx *context.T, call rpc.ServerCall, st store.StoreReader, v PermserData) (parentPerms, perms access.Permissions, existErr error) // PermserData returns a zero-value PermserData for this object. PermserData() PermserData }
Permser is an object in the hierarchy that supports retrieving perms and authorizing access to existence checks. Access checks on Permser objects using Get{Data,Perms}With*Auth functions below should be done in the same transaction as any store modification to ensure that concurrent ACL changes invalidate the modification.
type PermserData ¶
type PermserData interface { // GetPerms returns the perms for the object. GetPerms() access.Permissions }
PermserData is persistent metadata about an object, including perms.