tableacl

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 14 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentACLFactory

func GetCurrentACLFactory() (acl.Factory, error)

GetCurrentACLFactory returns current table acl implementation.

func GetCurrentConfig

func GetCurrentConfig() *tableaclpb.Config

GetCurrentConfig returns a copy of current tableacl configuration.

func Init

func Init(configFile string, aclCB func()) error

Init initiates table ACLs.

The config file can be binary-proto-encoded, or json-encoded. In the json case, it looks like this:

{
  "table_groups": [
    {
      "table_names_or_prefixes": ["name1"],
      "readers": ["client1"],
      "writers": ["client1"],
      "admins": ["client1"]
    }
  ]
}

func InitFromProto

func InitFromProto(config *tableaclpb.Config) error

InitFromProto inits table ACLs from a proto.

func Register

func Register(name string, factory acl.Factory)

Register registers an AclFactory.

func SetDefaultACL

func SetDefaultACL(name string)

SetDefaultACL sets the default ACL implementation.

func ValidateProto

func ValidateProto(config *tableaclpb.Config) (err error)

ValidateProto returns an error if the given proto has problems that would cause InitFromProto to fail.

Types

type ACLResult

type ACLResult struct {
	acl.ACL
	GroupName string
}

ACLResult embeds an acl.ACL and also tell which table group it belongs to.

func Authorized

func Authorized(table string, role Role) *ACLResult

Authorized returns the list of entities who have the specified role on a tablel.

func (*ACLResult) CachedSize added in v0.10.0

func (cached *ACLResult) CachedSize(alloc bool) int64

type Role

type Role int

Role defines the level of access on a table

const (
	// READER can run SELECT statements
	READER Role = iota
	// WRITER can run SELECT, INSERT & UPDATE statements
	WRITER
	// ADMIN can run any statements including DDLs
	ADMIN
	// NumRoles is number of Roles defined
	NumRoles
)

func RoleByName

func RoleByName(s string) (Role, bool)

RoleByName returns the Role corresponding to a name

func (Role) Name

func (r Role) Name() string

Name returns the name of a role

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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