Documentation ¶
Index ¶
- Constants
- Variables
- func BasePermissionsString(basePermissions BasePermissions) string
- func BasePermissionsToStringList(basePermissions BasePermissions) []string
- func PermFlagToStringList(permFlag PermFlag) []string
- func String(permFlag PermFlag) string
- type AccountPermissions
- func (ap *AccountPermissions) AddRole(role string) bool
- func (ap *AccountPermissions) Clone() AccountPermissions
- func (*AccountPermissions) Descriptor() ([]byte, []int)
- func (m *AccountPermissions) GetBase() BasePermissions
- func (m *AccountPermissions) GetRoles() []string
- func (ap AccountPermissions) HasRole(role string) bool
- func (m *AccountPermissions) Marshal() (dAtA []byte, err error)
- func (m *AccountPermissions) MarshalTo(dAtA []byte) (int, error)
- func (*AccountPermissions) ProtoMessage()
- func (ap *AccountPermissions) RemoveRole(role string) bool
- func (m *AccountPermissions) Reset()
- func (m *AccountPermissions) Size() (n int)
- func (m *AccountPermissions) String() string
- func (m *AccountPermissions) Unmarshal(dAtA []byte) error
- func (m *AccountPermissions) XXX_DiscardUnknown()
- func (m *AccountPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *AccountPermissions) XXX_Merge(src proto.Message)
- func (*AccountPermissions) XXX_MessageName() string
- func (m *AccountPermissions) XXX_Size() int
- func (m *AccountPermissions) XXX_Unmarshal(b []byte) error
- type BasePermissions
- func (bp BasePermissions) Compose(bpFallthrough BasePermissions) BasePermissions
- func (*BasePermissions) Descriptor() ([]byte, []int)
- func (bp BasePermissions) Get(ty PermFlag) (bool, error)
- func (m *BasePermissions) GetPerms() PermFlag
- func (m *BasePermissions) GetSetBit() PermFlag
- func (bp BasePermissions) IsSet(ty PermFlag) bool
- func (m *BasePermissions) Marshal() (dAtA []byte, err error)
- func (m *BasePermissions) MarshalTo(dAtA []byte) (int, error)
- func (*BasePermissions) ProtoMessage()
- func (m *BasePermissions) Reset()
- func (bp BasePermissions) ResultantPerms() PermFlag
- func (bp *BasePermissions) Set(ty PermFlag, value bool) error
- func (m *BasePermissions) Size() (n int)
- func (bp BasePermissions) String() string
- func (m *BasePermissions) Unmarshal(dAtA []byte) error
- func (bp *BasePermissions) Unset(ty PermFlag) error
- func (m *BasePermissions) XXX_DiscardUnknown()
- func (m *BasePermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *BasePermissions) XXX_Merge(src proto.Message)
- func (*BasePermissions) XXX_MessageName() string
- func (m *BasePermissions) XXX_Size() int
- func (m *BasePermissions) XXX_Unmarshal(b []byte) error
- type ErrInvalidPermission
- type ErrValueNotSet
- type PermArgs
- func AddRoleArgs(address crypto.Address, role string) PermArgs
- func HasBaseArgs(address crypto.Address, permFlag PermFlag) PermArgs
- func HasRoleArgs(address crypto.Address, role string) PermArgs
- func RemoveRoleArgs(address crypto.Address, role string) PermArgs
- func SetBaseArgs(address crypto.Address, permFlag PermFlag, value bool) PermArgs
- func SetGlobalArgs(permFlag PermFlag, value bool) PermArgs
- func UnsetBaseArgs(address crypto.Address, permFlag PermFlag) PermArgs
- func (*PermArgs) Descriptor() ([]byte, []int)
- func (pa PermArgs) EnsureValid() error
- func (m *PermArgs) GetAction() PermFlag
- func (m *PermArgs) GetPermission() PermFlag
- func (m *PermArgs) GetRole() string
- func (m *PermArgs) GetValue() bool
- func (m *PermArgs) Marshal() (dAtA []byte, err error)
- func (m *PermArgs) MarshalTo(dAtA []byte) (int, error)
- func (*PermArgs) ProtoMessage()
- func (m *PermArgs) Reset()
- func (m *PermArgs) Size() (n int)
- func (pa PermArgs) String() string
- func (m *PermArgs) Unmarshal(dAtA []byte) error
- func (m *PermArgs) XXX_DiscardUnknown()
- func (m *PermArgs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *PermArgs) XXX_Merge(src proto.Message)
- func (*PermArgs) XXX_MessageName() string
- func (m *PermArgs) XXX_Size() int
- func (m *PermArgs) XXX_Unmarshal(b []byte) error
- type PermFlag
Constants ¶
const ( // Chain permissions. // These permissions grant the ability for accounts to perform certain transition within the execution package // Root is a reserved permission currently unused that may be used in the future to grant super-user privileges // for instance to a governance contract Root PermFlag = 1 << iota // 1 // Send permits an account to issue a SendTx to transfer value from one account to another. Note that value can // still be transferred with a CallTx by specifying an Amount in the InputTx. Funding an account is the basic // prerequisite for an account to act in the system so is often used as a surrogate for 'account creation' when // sending to a unknown account - in order for this to be permitted the input account needs the CreateAccount // permission in addition. Send // 2 // Call permits and account to issue a CallTx, which can be used to call (run) the code of an existing // account/contract (these are synonymous in Burrow/EVM). A CallTx can be used to create an account if it points to // a nil address - in order for an account to be permitted to do this the input (calling) account needs the // CreateContract permission in addition. Call // 4 // CreateContract permits the input account of a CallTx to create a new contract/account when CallTx.Address is nil // and permits an executing contract in the EVM to create a new contract programmatically. CreateContract // 8 // CreateAccount permits an input account of a SendTx to add value to non-existing (unfunded) accounts CreateAccount // 16 // Bond is a reserved permission for making changes to the validator set - currently unused Bond // 32 // Name permits manipulation of the name registry by allowing an account to issue a NameTx Name // 64 // Propose permits creating proposals and voting for them Proposal // 128 // Input allows account to sign transactions Input // 256 // Permission to execute batch transactins Batch // 512 // Moderator permissions. // These permissions concern the alteration of the chain permissions listed above. Each permission relates to a // particular canonical permission mutation or query function. When an account is granted a moderation permission // it is permitted to call that function. See snative.go for a marked-up description of what each function does. HasBase SetBase UnsetBase SetGlobal HasRole AddRole RemoveRole NumPermissions uint = 17 // NOTE Adjust this too. We can support upto 64 TopPermFlag PermFlag = 1 << (NumPermissions - 1) AllPermFlags PermFlag = TopPermFlag | (TopPermFlag - 1) DefaultPermFlags PermFlag = Send | Call | CreateContract | CreateAccount | Bond | Name | HasBase | HasRole | Proposal | Input | Batch // Chain permissions strings RootString string = "root" SendString = "send" CallString = "call" CreateContractString = "createContract" CreateAccountString = "createAccount" BondString = "bond" NameString = "name" ProposalString = "proposal" InputString = "input" BatchString = "batch" // Moderator permissions strings HasBaseString = "hasBase" SetBaseString = "setBase" UnsetBaseString = "unsetBase" SetGlobalString = "setGlobal" HasRoleString = "hasRole" AddRoleString = "addRole" RemoveRoleString = "removeRole" UnknownString = "#-UNKNOWN-#" AllString = "all" )
Base permission references are like unix (the index is already bit shifted)
Variables ¶
var ( ErrInvalidLengthPermission = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowPermission = fmt.Errorf("proto: integer overflow") )
var ( ZeroBasePermissions = BasePermissions{ Perms: 0, SetBit: 0, } ZeroAccountPermissions = AccountPermissions{ Base: ZeroBasePermissions, } DefaultAccountPermissions = AccountPermissions{ Base: BasePermissions{ Perms: DefaultPermFlags, SetBit: AllPermFlags, }, Roles: []string{}, } AllAccountPermissions = AccountPermissions{ Base: BasePermissions{ Perms: AllPermFlags, SetBit: AllPermFlags, }, Roles: []string{}, } )
Functions ¶
func BasePermissionsString ¶
func BasePermissionsString(basePermissions BasePermissions) string
Generates a human readable string from the resultant permissions of basePermission
func BasePermissionsToStringList ¶
func BasePermissionsToStringList(basePermissions BasePermissions) []string
Builds a list of set permissions from a BasePermission by creating a list of permissions strings from the resultant permissions of basePermissions
func PermFlagToStringList ¶
Creates a list of individual permission flag strings from a possibly composite PermFlag by projecting out each bit and adding its permission string if it is set
Types ¶
type AccountPermissions ¶ added in v0.20.0
type AccountPermissions struct { Base BasePermissions `protobuf:"bytes,1,opt,name=Base" json:"Base"` Roles []string `protobuf:"bytes,2,rep,name=Roles" json:"Roles,omitempty"` XXX_unrecognized []byte `json:"-"` }
func ConvertPermissionsMapAndRolesToAccountPermissions ¶
func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]bool, roles []string) (*AccountPermissions, error)
ConvertMapStringIntToPermissions converts a map of string-bool pairs and a slice of strings for the roles to an AccountPermissions type. If the value in the permissions map is true for a particular permission string then the permission will be set in the AccountsPermissions. For all unmentioned permissions the ZeroBasePermissions is defaulted to.
func NewAccountPermissions ¶ added in v0.20.0
func NewAccountPermissions(pss ...PermFlag) AccountPermissions
func (*AccountPermissions) AddRole ¶ added in v0.20.0
func (ap *AccountPermissions) AddRole(role string) bool
Returns true if the role is added, and false if it already exists
func (*AccountPermissions) Clone ¶ added in v0.20.0
func (ap *AccountPermissions) Clone() AccountPermissions
Clone clones the account permissions
func (*AccountPermissions) Descriptor ¶ added in v0.20.0
func (*AccountPermissions) Descriptor() ([]byte, []int)
func (*AccountPermissions) GetBase ¶ added in v0.20.0
func (m *AccountPermissions) GetBase() BasePermissions
func (*AccountPermissions) GetRoles ¶ added in v0.20.0
func (m *AccountPermissions) GetRoles() []string
func (AccountPermissions) HasRole ¶ added in v0.20.0
func (ap AccountPermissions) HasRole(role string) bool
Returns true if the role is found
func (*AccountPermissions) Marshal ¶ added in v0.20.0
func (m *AccountPermissions) Marshal() (dAtA []byte, err error)
func (*AccountPermissions) MarshalTo ¶ added in v0.20.0
func (m *AccountPermissions) MarshalTo(dAtA []byte) (int, error)
func (*AccountPermissions) ProtoMessage ¶ added in v0.20.0
func (*AccountPermissions) ProtoMessage()
func (*AccountPermissions) RemoveRole ¶ added in v0.23.0
func (ap *AccountPermissions) RemoveRole(role string) bool
Returns true if the role is removed, and false if it is not found
func (*AccountPermissions) Reset ¶ added in v0.20.0
func (m *AccountPermissions) Reset()
func (*AccountPermissions) Size ¶ added in v0.20.0
func (m *AccountPermissions) Size() (n int)
func (*AccountPermissions) String ¶ added in v0.20.0
func (m *AccountPermissions) String() string
func (*AccountPermissions) Unmarshal ¶ added in v0.20.0
func (m *AccountPermissions) Unmarshal(dAtA []byte) error
func (*AccountPermissions) XXX_DiscardUnknown ¶ added in v0.23.0
func (m *AccountPermissions) XXX_DiscardUnknown()
func (*AccountPermissions) XXX_Marshal ¶ added in v0.23.0
func (m *AccountPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AccountPermissions) XXX_Merge ¶ added in v0.23.0
func (dst *AccountPermissions) XXX_Merge(src proto.Message)
func (*AccountPermissions) XXX_MessageName ¶ added in v0.20.0
func (*AccountPermissions) XXX_MessageName() string
func (*AccountPermissions) XXX_Size ¶ added in v0.23.0
func (m *AccountPermissions) XXX_Size() int
func (*AccountPermissions) XXX_Unmarshal ¶ added in v0.23.0
func (m *AccountPermissions) XXX_Unmarshal(b []byte) error
type BasePermissions ¶ added in v0.20.0
type BasePermissions struct { Perms PermFlag `protobuf:"varint,1,opt,name=Perms,casttype=PermFlag" json:"Perms"` SetBit PermFlag `protobuf:"varint,2,opt,name=SetBit,casttype=PermFlag" json:"SetBit"` XXX_unrecognized []byte `json:"-"` }
func BasePermissionsFromStringList ¶
func BasePermissionsFromStringList(permissions []string) (BasePermissions, error)
Builds a composite BasePermission by creating a PermFlag from permissions strings and setting them all
func (BasePermissions) Compose ¶ added in v0.20.0
func (bp BasePermissions) Compose(bpFallthrough BasePermissions) BasePermissions
Returns a BasePermission that matches any permissions set on this BasePermission and falls through to any permissions set on the bpFallthrough
func (*BasePermissions) Descriptor ¶ added in v0.20.0
func (*BasePermissions) Descriptor() ([]byte, []int)
func (BasePermissions) Get ¶ added in v0.20.0
func (bp BasePermissions) Get(ty PermFlag) (bool, error)
Gets the permission value. ErrValueNotSet is returned if the permission's set bits are not all on, and should be caught by caller so the global permission can be fetched
func (*BasePermissions) GetPerms ¶ added in v0.20.0
func (m *BasePermissions) GetPerms() PermFlag
func (*BasePermissions) GetSetBit ¶ added in v0.20.0
func (m *BasePermissions) GetSetBit() PermFlag
func (BasePermissions) IsSet ¶ added in v0.20.0
func (bp BasePermissions) IsSet(ty PermFlag) bool
Check if the permission is set
func (*BasePermissions) Marshal ¶ added in v0.20.0
func (m *BasePermissions) Marshal() (dAtA []byte, err error)
func (*BasePermissions) MarshalTo ¶ added in v0.20.0
func (m *BasePermissions) MarshalTo(dAtA []byte) (int, error)
func (*BasePermissions) ProtoMessage ¶ added in v0.20.0
func (*BasePermissions) ProtoMessage()
func (*BasePermissions) Reset ¶ added in v0.20.0
func (m *BasePermissions) Reset()
func (BasePermissions) ResultantPerms ¶ added in v0.20.0
func (bp BasePermissions) ResultantPerms() PermFlag
Returns the Perms PermFlag masked with SetBit bit field to give the resultant permissions enabled by this BasePermissions
func (*BasePermissions) Set ¶ added in v0.20.0
func (bp *BasePermissions) Set(ty PermFlag, value bool) error
Set a permission bit. Will set the permission's set bit to true.
func (*BasePermissions) Size ¶ added in v0.20.0
func (m *BasePermissions) Size() (n int)
func (BasePermissions) String ¶ added in v0.20.0
func (bp BasePermissions) String() string
func (*BasePermissions) Unmarshal ¶ added in v0.20.0
func (m *BasePermissions) Unmarshal(dAtA []byte) error
func (*BasePermissions) Unset ¶ added in v0.20.0
func (bp *BasePermissions) Unset(ty PermFlag) error
Set the permission's set bits to false
func (*BasePermissions) XXX_DiscardUnknown ¶ added in v0.23.0
func (m *BasePermissions) XXX_DiscardUnknown()
func (*BasePermissions) XXX_Marshal ¶ added in v0.23.0
func (m *BasePermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*BasePermissions) XXX_Merge ¶ added in v0.23.0
func (dst *BasePermissions) XXX_Merge(src proto.Message)
func (*BasePermissions) XXX_MessageName ¶ added in v0.20.0
func (*BasePermissions) XXX_MessageName() string
func (*BasePermissions) XXX_Size ¶ added in v0.23.0
func (m *BasePermissions) XXX_Size() int
func (*BasePermissions) XXX_Unmarshal ¶ added in v0.23.0
func (m *BasePermissions) XXX_Unmarshal(b []byte) error
type ErrInvalidPermission ¶ added in v0.20.0
type ErrInvalidPermission PermFlag
func (ErrInvalidPermission) Error ¶ added in v0.20.0
func (e ErrInvalidPermission) Error() string
type ErrValueNotSet ¶ added in v0.20.0
type ErrValueNotSet PermFlag
set=false. This error should be caught and the global value fetched for the permission by the caller
func (ErrValueNotSet) Error ¶ added in v0.20.0
func (e ErrValueNotSet) Error() string
type PermArgs ¶ added in v0.20.0
type PermArgs struct { // The permission function Action PermFlag `protobuf:"varint,1,opt,name=Action,casttype=PermFlag" json:"Action"` // The target of the action Target *github_com_hyperledger_burrow_crypto.Address `protobuf:"bytes,2,opt,name=Target,customtype=github.com/hyperledger/burrow/crypto.Address" json:"Target,omitempty"` // Possible arguments Permission *PermFlag `protobuf:"varint,3,opt,name=Permission,casttype=PermFlag" json:"Permission,omitempty"` Role *string `protobuf:"bytes,4,opt,name=Role" json:"Role,omitempty"` Value *bool `protobuf:"varint,5,opt,name=Value" json:"Value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_sizecache int32 `json:"-"` }
func HasBaseArgs ¶ added in v0.20.0
func RemoveRoleArgs ¶ added in v0.20.0
func SetBaseArgs ¶ added in v0.20.0
func SetGlobalArgs ¶ added in v0.20.0
func UnsetBaseArgs ¶ added in v0.20.0
func (*PermArgs) Descriptor ¶ added in v0.20.0
func (PermArgs) EnsureValid ¶ added in v0.20.0
func (*PermArgs) GetPermission ¶ added in v0.20.0
func (*PermArgs) ProtoMessage ¶ added in v0.20.0
func (*PermArgs) ProtoMessage()
func (*PermArgs) XXX_DiscardUnknown ¶ added in v0.23.0
func (m *PermArgs) XXX_DiscardUnknown()
func (*PermArgs) XXX_Marshal ¶ added in v0.23.0
func (*PermArgs) XXX_MessageName ¶ added in v0.20.0
func (*PermArgs) XXX_Unmarshal ¶ added in v0.23.0
type PermFlag ¶ added in v0.20.0
type PermFlag uint64
A particular permission
func PermFlagFromStringList ¶
Builds a composite PermFlag by mapping each permission string in permissions to its flag and composing them with binary or
func PermStringToFlag ¶
PermStringToFlag maps camel- and snake case strings to the the corresponding permission flag.
func (PermFlag) IsValid ¶ added in v0.20.0
Checks if a permission flag is valid (a known base chain or snative permission)
func (PermFlag) MarshalText ¶ added in v0.23.0
func (PermFlag) String ¶ added in v0.20.0
Returns the string name of a single bit non-composite PermFlag, or otherwise UnknownString See BasePermissionsToStringList to generate a string representation of a composite PermFlag