Documentation ¶
Index ¶
- 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) 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) 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) 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) 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) 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 ¶
This section is empty.
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) FromString ¶
FromString parses Action from a string representation. It is a reverse action to String().
Returns true if s was parsed successfully.
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) FromString ¶
func (h *FilterHeaderType) FromString(s string) bool
FromString parses FilterHeaderType from a string representation. It is a reverse action to String().
Returns true if s was parsed successfully.
func (FilterHeaderType) String ¶
func (h FilterHeaderType) String() string
String returns string representation of FilterHeaderType.
String mapping:
- HeaderFromRequest: REQUEST;
- HeaderFromObject: OBJECT;
- HeaderTypeUnknown, default: HEADER_UNSPECIFIED.
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.
func MatchFromV2 ¶
MatchFromV2 converts v2 MatchType enum value to Match.
func (*Match) FromString ¶
FromString parses Match from a string representation. It is a reverse action to String().
Returns true if s was parsed successfully.
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) FromString ¶
FromString parses Operation from a string representation. It is a reverse action to String().
Returns true if s was parsed successfully.
func (Operation) String ¶
String 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.
func (*Record) AddObjectAttributeFilter ¶
AddObjectAttributeFilter adds filter by object attribute.
func (*Record) AddObjectContainerIDFilter ¶
AddObjectContainerIDFilter adds filter by object container ID.
func (*Record) AddObjectCreationEpoch ¶
AddObjectCreationEpoch adds filter by object creation epoch.
func (*Record) AddObjectHomomorphicHashFilter ¶
AddObjectHomomorphicHashFilter adds filter by object payload homomorphic hash value.
func (*Record) AddObjectIDFilter ¶
AddObjectIDFilter adds filter by object ID.
func (*Record) AddObjectOwnerIDFilter ¶
AddObjectOwnerIDFilter adds filter by object owner ID.
func (*Record) AddObjectPayloadHashFilter ¶
AddObjectPayloadHashFilter adds filter by object payload hash value.
func (*Record) AddObjectPayloadLengthFilter ¶
AddObjectPayloadLengthFilter adds filter by object payload length.
func (*Record) AddObjectTypeFilter ¶
AddObjectTypeFilter adds filter by object type.
func (*Record) AddObjectVersionFilter ¶
AddObjectVersionFilter adds filter by object version.
func (*Record) MarshalJSON ¶
MarshalJSON encodes Record to protobuf JSON format.
func (*Record) SetOperation ¶
SetOperation sets FrostFS request verb to match.
func (*Record) SetTargets ¶
SetTargets sets list of target subjects to apply ACL rule to.
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) FromString ¶
FromString parses Role from a string representation. It is a reverse action to String().
Returns true if s was parsed successfully.
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) 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) 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.
func (*Target) MarshalJSON ¶
MarshalJSON encodes Target to protobuf JSON format.
func (*Target) SetBinaryKeys ¶
SetBinaryKeys sets list of binary public keys to identify target subject.
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.
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.