Documentation ¶
Index ¶
- Constants
- func AddFormedTarget(r *Record, role Role, keys ...ecdsa.PublicKey)
- func AddRecordTarget(r *Record, t *Target)
- func EqualTables(t1, t2 Table) bool
- func SetTargetECDSAKeys(t *Target, pubs ...*ecdsa.PublicKey)
- func TargetECDSAKeys(t *Target) []*ecdsa.PublicKey
- type Action
- type Filter
- func (f Filter) CopyTo(dst *Filter)
- func (f Filter) From() FilterHeaderType
- func (f Filter) Key() string
- func (f *Filter) Marshal() ([]byte, error)
- func (f *Filter) MarshalJSON() ([]byte, error)
- func (f Filter) Matcher() Match
- func (f *Filter) ToV2() *v2acl.HeaderFilter
- func (f *Filter) Unmarshal(data []byte) error
- func (f *Filter) UnmarshalJSON(data []byte) error
- func (f Filter) Value() string
- type FilterHeaderType
- type Header
- type Match
- type Operation
- type Record
- func (r Record) Action() Action
- func (r *Record) AddFilter(from FilterHeaderType, matcher Match, name, value string)
- func (r *Record) AddObjectAttributeFilter(m Match, key, value string)
- func (r *Record) AddObjectContainerIDFilter(m Match, id cid.ID)
- func (r *Record) AddObjectCreationEpoch(m Match, epoch uint64)
- func (r *Record) AddObjectHomomorphicHashFilter(m Match, h checksum.Checksum)
- func (r *Record) AddObjectIDFilter(m Match, id oid.ID)
- func (r *Record) AddObjectOwnerIDFilter(m Match, id *user.ID)
- func (r *Record) AddObjectPayloadHashFilter(m Match, h checksum.Checksum)
- func (r *Record) AddObjectPayloadLengthFilter(m Match, size uint64)
- func (r *Record) AddObjectTypeFilter(m Match, t object.Type)
- func (r *Record) AddObjectVersionFilter(m Match, v *version.Version)
- func (r Record) CopyTo(dst *Record)
- func (r Record) Filters() []Filter
- func (r *Record) Marshal() ([]byte, error)
- func (r *Record) MarshalJSON() ([]byte, error)
- func (r Record) Operation() Operation
- func (r *Record) SetAction(action Action)
- func (r *Record) SetOperation(operation Operation)
- func (r *Record) SetTargets(targets ...Target)
- func (r Record) Targets() []Target
- func (r *Record) ToV2() *v2acl.Record
- func (r *Record) Unmarshal(data []byte) error
- func (r *Record) UnmarshalJSON(data []byte) error
- type Role
- type Table
- func (t *Table) AddRecord(r *Record)
- func (t Table) CID() (cID cid.ID, isSet bool)
- func (t Table) CopyTo(dst *Table)
- func (t *Table) Marshal() ([]byte, error)
- func (t *Table) MarshalJSON() ([]byte, error)
- func (t Table) Records() []Record
- func (t *Table) SetCID(cid cid.ID)
- func (t *Table) SetVersion(version version.Version)
- func (t Table) SignedData() []byte
- func (t *Table) ToV2() *v2acl.Table
- func (t *Table) Unmarshal(data []byte) error
- func (t *Table) UnmarshalJSON(data []byte) error
- func (t Table) Version() version.Version
- type Target
- func (t *Target) BinaryKeys() [][]byte
- func (t Target) CopyTo(dst *Target)
- func (t *Target) Marshal() ([]byte, error)
- func (t *Target) MarshalJSON() ([]byte, error)
- func (t Target) Role() Role
- func (t *Target) SetBinaryKeys(keys [][]byte)
- func (t *Target) SetRole(r Role)
- func (t *Target) ToV2() *v2acl.Target
- func (t *Target) Unmarshal(data []byte) error
- func (t *Target) UnmarshalJSON(data []byte) error
- type TypedHeaderSource
- type ValidationUnit
- func (u *ValidationUnit) WithContainerID(v *cid.ID) *ValidationUnit
- func (u *ValidationUnit) WithEACLTable(table *Table) *ValidationUnit
- func (u *ValidationUnit) WithHeaderSource(v TypedHeaderSource) *ValidationUnit
- func (u *ValidationUnit) WithOperation(v Operation) *ValidationUnit
- func (u *ValidationUnit) WithRole(v Role) *ValidationUnit
- func (u *ValidationUnit) WithSenderKey(v []byte) *ValidationUnit
- type Validator
Constants ¶
const ( FilterObjectVersion = v2acl.FilterObjectVersion FilterObjectID = v2acl.FilterObjectID FilterObjectContainerID = v2acl.FilterObjectContainerID FilterObjectOwnerID = v2acl.FilterObjectOwnerID FilterObjectCreationEpoch = v2acl.FilterObjectCreationEpoch FilterObjectPayloadSize = v2acl.FilterObjectPayloadLength FilterObjectPayloadChecksum = v2acl.FilterObjectPayloadHash FilterObjectType = v2acl.FilterObjectType FilterObjectPayloadHomomorphicChecksum = v2acl.FilterObjectHomomorphicHash )
Various keys to object filters.
Variables ¶
This section is empty.
Functions ¶
func AddFormedTarget ¶
AddFormedTarget forms Target with specified Role and list of ECDSA public keys and adds it to the Record.
func AddRecordTarget ¶
AddRecordTarget adds single Target to the Record.
func SetTargetECDSAKeys ¶
SetTargetECDSAKeys converts ECDSA public keys to a binary format and stores them in Target.
func TargetECDSAKeys ¶
TargetECDSAKeys interprets binary public keys of Target as ECDSA public keys. If any key has a different format, the corresponding element will be nil.
Types ¶
type Action ¶
type Action uint32
Action taken if ContainerEACL record matched request. Action is compatible with v2 acl.Action enum.
func ActionFromV2 ¶
ActionFromV2 converts v2 Action enum value to Action.
func (*Action) DecodeString ¶
DecodeString parses Action from a string representation. It is a reverse action to EncodeToString().
Returns true if s was parsed successfully.
func (Action) EncodeToString ¶
EncodeToString returns string representation of Action.
String mapping:
- ActionAllow: ALLOW;
- ActionDeny: DENY;
- ActionUnknown, default: ACTION_UNSPECIFIED.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter defines check conditions if request header is matched or not. Matched header means that request should be processed according to ContainerEACL action.
Filter is compatible with v2 acl.EACLRecord.Filter message.
func NewFilter ¶
func NewFilter() *Filter
NewFilter creates, initializes and returns blank Filter instance.
Defaults:
- header type: HeaderTypeUnknown;
- matcher: MatchUnknown;
- key: "";
- value: "".
func NewFilterFromV2 ¶
func NewFilterFromV2(filter *v2acl.HeaderFilter) *Filter
NewFilterFromV2 converts v2 acl.EACLRecord.Filter message to Filter.
func (Filter) From ¶
func (f Filter) From() FilterHeaderType
From returns FilterHeaderType that defined which header will be filtered.
func (*Filter) MarshalJSON ¶
MarshalJSON encodes Filter to protobuf JSON format.
func (*Filter) ToV2 ¶
func (f *Filter) ToV2() *v2acl.HeaderFilter
ToV2 converts Filter to v2 acl.EACLRecord.Filter message.
Nil Filter converts to nil.
func (*Filter) UnmarshalJSON ¶
UnmarshalJSON decodes Filter from protobuf JSON format.
type FilterHeaderType ¶
type FilterHeaderType uint32
FilterHeaderType indicates source of headers to make matches. FilterHeaderType is compatible with v2 acl.HeaderType enum.
const ( // HeaderTypeUnknown is a FilterHeaderType value used to mark header type as undefined. HeaderTypeUnknown FilterHeaderType = iota // HeaderFromRequest is a FilterHeaderType for request X-Header. HeaderFromRequest // HeaderFromObject is a FilterHeaderType for object header. HeaderFromObject // HeaderFromService is a FilterHeaderType for service header. HeaderFromService )
func FilterHeaderTypeFromV2 ¶
func FilterHeaderTypeFromV2(header v2acl.HeaderType) (h FilterHeaderType)
FilterHeaderTypeFromV2 converts v2 HeaderType enum value to FilterHeaderType.
func (*FilterHeaderType) DecodeString ¶
func (h *FilterHeaderType) DecodeString(s string) bool
DecodeString parses FilterHeaderType from a string representation. It is a reverse action to EncodeToString().
Returns true if s was parsed successfully.
func (FilterHeaderType) EncodeToString ¶
func (h FilterHeaderType) EncodeToString() string
EncodeToString returns string representation of FilterHeaderType.
String mapping:
- HeaderFromRequest: REQUEST;
- HeaderFromObject: OBJECT;
- HeaderTypeUnknown, default: HEADER_UNSPECIFIED.
func (FilterHeaderType) String ¶
func (h FilterHeaderType) String() string
String implements fmt.Stringer.
String is designed to be human-readable, and its format MAY differ between SDK versions. String MAY return same result as EncodeToString. String MUST NOT be used to encode ID into NeoFS protocol string.
func (FilterHeaderType) ToV2 ¶
func (h FilterHeaderType) ToV2() v2acl.HeaderType
ToV2 converts FilterHeaderType to v2 HeaderType enum value.
type Match ¶
type Match uint32
Match is binary operation on filer name and value to check if request is matched. Match is compatible with v2 acl.MatchType enum.
const ( // MatchUnknown is a Match value used to mark matcher as undefined. MatchUnknown Match = iota // MatchStringEqual is a Match of string equality. MatchStringEqual // MatchStringNotEqual is a Match of string inequality. MatchStringNotEqual // MatchNotPresent is an operator for attribute absence. MatchNotPresent // MatchNumGT is a numeric "greater than" operator. MatchNumGT // MatchNumGE is a numeric "greater or equal than" operator. MatchNumGE // MatchNumLT is a numeric "less than" operator. MatchNumLT // MatchNumLE is a numeric "less or equal than" operator. MatchNumLE )
func MatchFromV2 ¶
MatchFromV2 converts v2 MatchType enum value to Match.
func (*Match) DecodeString ¶
DecodeString parses Match from a string representation. It is a reverse action to EncodeToString().
Returns true if s was parsed successfully.
func (Match) EncodeToString ¶
EncodeToString returns string representation of Match.
String mapping:
- MatchStringEqual: STRING_EQUAL;
- MatchStringNotEqual: STRING_NOT_EQUAL;
- MatchNotPresent: NOT_PRESENT;
- MatchNumGT: NUM_GT;
- MatchNumGE: NUM_GE;
- MatchNumLT: NUM_LT;
- MatchNumLE: NUM_LE;
- MatchUnknown, default: MATCH_TYPE_UNSPECIFIED.
type Operation ¶
type Operation uint32
Operation is a object service method to match request. Operation is compatible with v2 acl.Operation enum.
const ( // OperationUnknown is an Operation value used to mark operation as undefined. OperationUnknown Operation = iota // OperationGet is an object get Operation. OperationGet // OperationHead is an Operation of getting the object header. OperationHead // OperationPut is an object put Operation. OperationPut // OperationDelete is an object delete Operation. OperationDelete // OperationSearch is an object search Operation. OperationSearch // OperationRange is an object payload range retrieval Operation. OperationRange // OperationRangeHash is an object payload range hashing Operation. OperationRangeHash )
func OperationFromV2 ¶
OperationFromV2 converts v2 Operation enum value to Operation.
func (*Operation) DecodeString ¶
DecodeString parses Operation from a string representation. It is a reverse action to EncodeToString().
Returns true if s was parsed successfully.
func (Operation) EncodeToString ¶
EncodeToString returns string representation of Operation.
String mapping:
- OperationGet: GET;
- OperationHead: HEAD;
- OperationPut: PUT;
- OperationDelete: DELETE;
- OperationSearch: SEARCH;
- OperationRange: GETRANGE;
- OperationRangeHash: GETRANGEHASH;
- OperationUnknown, default: OPERATION_UNSPECIFIED.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record of the ContainerEACL rule, that defines ContainerEACL action, targets for this action, object service operation and filters for request headers.
Record is compatible with v2 acl.EACLRecord message.
func CreateRecord ¶
CreateRecord creates, initializes with parameters and returns Record instance.
func NewRecord ¶
func NewRecord() *Record
NewRecord creates and returns blank Record instance.
Defaults:
- action: ActionUnknown;
- operation: OperationUnknown;
- targets: nil,
- filters: nil.
func NewRecordFromV2 ¶
NewRecordFromV2 converts v2 acl.EACLRecord message to Record.
func (*Record) AddFilter ¶
func (r *Record) AddFilter(from FilterHeaderType, matcher Match, name, value string)
AddFilter adds generic filter.
If matcher is MatchNotPresent, the value must be empty. If matcher is numeric (e.g. MatchNumGT), value must be a base-10 integer.
func (*Record) AddObjectAttributeFilter ¶
AddObjectAttributeFilter adds filter by object attribute.
If m is MatchNotPresent, the value must be empty. If matcher is numeric (e.g. MatchNumGT), value must be a base-10 integer.
func (*Record) AddObjectContainerIDFilter ¶
AddObjectContainerIDFilter adds filter by object container ID.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (*Record) AddObjectCreationEpoch ¶
AddObjectCreationEpoch adds filter by object creation epoch.
The m must not be MatchNotPresent.
func (*Record) AddObjectHomomorphicHashFilter ¶
AddObjectHomomorphicHashFilter adds filter by object payload homomorphic hash value.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (*Record) AddObjectIDFilter ¶
AddObjectIDFilter adds filter by object ID.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (*Record) AddObjectOwnerIDFilter ¶
AddObjectOwnerIDFilter adds filter by object owner ID.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (*Record) AddObjectPayloadHashFilter ¶
AddObjectPayloadHashFilter adds filter by object payload hash value.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (*Record) AddObjectPayloadLengthFilter ¶
AddObjectPayloadLengthFilter adds filter by object payload length.
The m must not be MatchNotPresent.
func (*Record) AddObjectTypeFilter ¶
AddObjectTypeFilter adds filter by object type.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (*Record) AddObjectVersionFilter ¶
AddObjectVersionFilter adds filter by object version.
The m must not be MatchNotPresent or numeric (e.g. MatchNumGT).
func (Record) Filters ¶
Filters returns list of filters to match and see if rule is applicable.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (*Record) MarshalJSON ¶
MarshalJSON encodes Record to protobuf JSON format.
func (*Record) SetOperation ¶
SetOperation sets NeoFS request verb to match.
func (*Record) SetTargets ¶
SetTargets sets list of target subjects to apply ACL rule to.
func (Record) Targets ¶
Targets returns list of target subjects to apply ACL rule to.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (*Record) ToV2 ¶
ToV2 converts Record to v2 acl.EACLRecord message.
Nil Record converts to nil.
func (*Record) UnmarshalJSON ¶
UnmarshalJSON decodes Record from protobuf JSON format.
type Role ¶
type Role uint32
Role is a group of request senders to match request. Role is compatible with v2 acl.Role enum.
const ( // RoleUnknown is a Role value used to mark role as undefined. RoleUnknown Role = iota // RoleUser is a group of senders that contains only key of container owner. RoleUser // RoleSystem is a group of senders that contains keys of container nodes and // inner ring nodes. RoleSystem // RoleOthers is a group of senders that contains none of above keys. RoleOthers )
func RoleFromV2 ¶
RoleFromV2 converts v2 Role enum value to Role.
func (*Role) DecodeString ¶
DecodeString parses Role from a string representation. It is a reverse action to EncodeToString().
Returns true if s was parsed successfully.
func (Role) EncodeToString ¶
EncodeToString returns string representation of Role.
String mapping:
- RoleUser: USER;
- RoleSystem: SYSTEM;
- RoleOthers: OTHERS;
- RoleUnknown, default: ROLE_UNKNOWN.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a group of ContainerEACL records for single container.
Table is compatible with v2 acl.EACLTable message.
func CreateTable ¶
CreateTable creates, initializes with parameters and returns Table instance.
func NewTable ¶
func NewTable() *Table
NewTable creates, initializes and returns blank Table instance.
Defaults:
- version: version.Current();
- container ID: nil;
- records: nil;
- session token: nil;
- signature: nil.
func NewTableFromV2 ¶
NewTableFromV2 converts v2 acl.EACLTable message to Table.
func (Table) CID ¶
CID returns identifier of the container that should use given access control rules.
func (*Table) MarshalJSON ¶
MarshalJSON encodes Table to protobuf JSON format.
func (Table) Records ¶
Records returns list of extended ACL rules.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (*Table) SetCID ¶
SetCID sets identifier of the container that should use given access control rules.
func (*Table) SetVersion ¶
SetVersion sets version of eACL format.
func (Table) SignedData ¶
SignedData returns actual payload to sign.
See also [client.Client.ContainerSetEACL].
func (*Table) UnmarshalJSON ¶
UnmarshalJSON decodes Table from protobuf JSON format.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target is a group of request senders to match ContainerEACL. Defined by role enum and set of public keys.
Target is compatible with v2 acl.EACLRecord.Target message.
func NewTarget ¶
func NewTarget() *Target
NewTarget creates, initializes and returns blank Target instance.
Defaults:
- role: RoleUnknown;
- keys: nil.
func NewTargetFromV2 ¶
NewTargetFromV2 converts v2 acl.EACLRecord.Target message to Target.
func (*Target) BinaryKeys ¶
BinaryKeys returns list of public keys to identify target subject in a binary format.
Each element of the resulting slice is a serialized compressed public key. See [elliptic.MarshalCompressed]. Use [neofsecdsa.PublicKey.Decode] to decode it into a type-specific structure.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (*Target) MarshalJSON ¶
MarshalJSON encodes Target to protobuf JSON format.
func (*Target) SetBinaryKeys ¶
SetBinaryKeys sets list of binary public keys to identify target subject.
Each element of the keys parameter is a slice of bytes is a serialized compressed public key. See [elliptic.MarshalCompressed].
func (*Target) ToV2 ¶
ToV2 converts Target to v2 acl.EACLRecord.Target message.
Nil Target converts to nil.
func (*Target) UnmarshalJSON ¶
UnmarshalJSON decodes Target from protobuf JSON format.
type TypedHeaderSource ¶
type TypedHeaderSource interface { // HeadersOfType returns the list of key-value headers // of particular type. // // It returns any problem encountered through the boolean // false value. HeadersOfType(FilterHeaderType) ([]Header, bool) }
TypedHeaderSource is the interface that wraps method for selecting typed headers by type.
type ValidationUnit ¶
type ValidationUnit struct {
// contains filtered or unexported fields
}
ValidationUnit represents unit of check for Validator.
func (*ValidationUnit) WithContainerID ¶
func (u *ValidationUnit) WithContainerID(v *cid.ID) *ValidationUnit
WithContainerID configures ValidationUnit to use v as request's container ID.
func (*ValidationUnit) WithEACLTable ¶
func (u *ValidationUnit) WithEACLTable(table *Table) *ValidationUnit
WithBearerToken configures ValidationUnit to use v as request's bearer token.
func (*ValidationUnit) WithHeaderSource ¶
func (u *ValidationUnit) WithHeaderSource(v TypedHeaderSource) *ValidationUnit
WithHeaderSource configures ValidationUnit to use v as a source of headers.
func (*ValidationUnit) WithOperation ¶
func (u *ValidationUnit) WithOperation(v Operation) *ValidationUnit
WithOperation configures ValidationUnit to use v as request's operation.
func (*ValidationUnit) WithRole ¶
func (u *ValidationUnit) WithRole(v Role) *ValidationUnit
WithRole configures ValidationUnit to use v as request's role.
func (*ValidationUnit) WithSenderKey ¶
func (u *ValidationUnit) WithSenderKey(v []byte) *ValidationUnit
WithSenderKey configures ValidationUnit to use as sender's public key.
Parameter v is a serialized compressed public key. See [elliptic.MarshalCompressed].
type Validator ¶
type Validator struct { }
Validator is a tool that calculates the action on a request according to the extended ACL rule table.
func NewValidator ¶
func NewValidator() *Validator
NewValidator creates and initializes a new Validator using options.
func (*Validator) CalculateAction ¶
func (v *Validator) CalculateAction(unit *ValidationUnit) (Action, bool)
CalculateAction calculates action on the request according to its information represented in ValidationUnit.
The action is calculated according to the application of eACL table of rules to the request.
Second return value is true iff the action was produced by a matching entry.
If no matching table entry is found or some filters are missing, ActionAllow is returned and the second return value is false.
Note that if some rule imposes requirements on the format of values (like numeric), but they do not comply with it - such a rule does not match.