Skip to content

Commit 541cd3c

Browse files
committed
object: Support numeric comparisons in access rules
Previously, protocol did not support numeric comparisons in access rules except `==` and `!=`. This may be needed for system attributes such as payload size or creation epoch, and for user ones if required by the client application. New values of `MatchType` enumeration are added: `>`, `>=`, `<`, `<=`. Being set in the `EACLRecord.Filter`, these operators will allow user to apply access rules with any decimal attributes. While only base-10 numbers are allowed, additional bases may be supported in the future without new enumerations. Closes #255. Refs #265. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent 5c8514d commit 541cd3c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

acl/types.proto

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ enum MatchType {
3636

3737
// Absence of attribute
3838
NOT_PRESENT = 3;
39+
40+
// Numeric 'greater than'
41+
NUM_GT = 4;
42+
43+
// Numeric 'greater or equal than'
44+
NUM_GE = 5;
45+
46+
// Numeric 'less than'
47+
NUM_LT = 6;
48+
49+
// Numeric 'less or equal than'
50+
NUM_LE = 7;
3951
}
4052

4153
// Request's operation type to match if the rule is applicable to a particular
@@ -106,7 +118,8 @@ message EACLRecord {
106118
// Filter to check particular properties of the request or the object.
107119
//
108120
// The `value` field must be empty if `match_type` is an unary operator
109-
// (e.g. `NOT_PRESENT`).
121+
// (e.g. `NOT_PRESENT`). If `match_type` field is numeric (e.g. `NUM_GT`),
122+
// the `value` field must be a base-10 integer.
110123
//
111124
// By default `key` field refers to the corresponding object's `Attribute`.
112125
// Some Object's header fields can also be accessed by adding `$Object:`
@@ -132,6 +145,9 @@ message EACLRecord {
132145
// * $Object:homomorphicHash \
133146
// homomorphic_hash
134147
//
148+
// Numeric `match_type` field can only be used with `$Object:creationEpoch`
149+
// and `$Object:payloadLength` system attributes.
150+
//
135151
// Please note, that if request or response does not have object's headers of
136152
// full object (Range, RangeHash, Search, Delete), it will not be possible to
137153
// filter by object header fields or user attributes. From the well-known list

proto-docs/acl.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ Describes a single eACL rule.
9696
Filter to check particular properties of the request or the object.
9797

9898
The `value` field must be empty if `match_type` is an unary operator
99-
(e.g. `NOT_PRESENT`).
99+
(e.g. `NOT_PRESENT`). If `match_type` field is numeric (e.g. `NUM_GT`),
100+
the `value` field must be a base-10 integer.
100101

101102
By default `key` field refers to the corresponding object's `Attribute`.
102103
Some Object's header fields can also be accessed by adding `$Object:`
@@ -122,6 +123,9 @@ prefix to the name. For such attributes, field 'match_type' must not be
122123
* $Object:homomorphicHash \
123124
homomorphic_hash
124125

126+
Numeric `match_type` field can only be used with `$Object:creationEpoch`
127+
and `$Object:payloadLength` system attributes.
128+
125129
Please note, that if request or response does not have object's headers of
126130
full object (Range, RangeHash, Search, Delete), it will not be possible to
127131
filter by object header fields or user attributes. From the well-known list
@@ -207,6 +211,10 @@ MatchType is an enumeration of match types.
207211
| STRING_EQUAL | 1 | Return true if strings are equal |
208212
| STRING_NOT_EQUAL | 2 | Return true if strings are different |
209213
| NOT_PRESENT | 3 | Absence of attribute |
214+
| NUM_GT | 4 | Numeric 'greater than' |
215+
| NUM_GE | 5 | Numeric 'greater or equal than' |
216+
| NUM_LT | 6 | Numeric 'less than' |
217+
| NUM_LE | 7 | Numeric 'less or equal than' |
210218

211219

212220

0 commit comments

Comments
 (0)