2020-08-17 09:16:52 +00:00
|
|
|
package acl
|
|
|
|
|
2024-05-28 08:54:38 +00:00
|
|
|
import (
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
)
|
2020-08-17 09:16:52 +00:00
|
|
|
|
2020-08-17 14:47:43 +00:00
|
|
|
// HeaderFilter is a unified structure of FilterInfo
|
|
|
|
// message from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type HeaderFilter struct {
|
|
|
|
hdrType HeaderType
|
|
|
|
|
|
|
|
matchType MatchType
|
|
|
|
|
2020-10-27 13:55:19 +00:00
|
|
|
key, value string
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-10 10:01:31 +00:00
|
|
|
// Target is a unified structure of Target
|
2020-08-17 14:47:43 +00:00
|
|
|
// message from proto definition.
|
2020-09-10 10:01:31 +00:00
|
|
|
type Target struct {
|
2020-09-04 07:50:36 +00:00
|
|
|
role Role
|
2020-08-17 09:16:52 +00:00
|
|
|
|
|
|
|
keys [][]byte
|
|
|
|
}
|
|
|
|
|
2020-08-17 14:47:43 +00:00
|
|
|
// Record is a unified structure of EACLRecord
|
|
|
|
// message from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type Record struct {
|
|
|
|
op Operation
|
|
|
|
|
|
|
|
action Action
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
filters []HeaderFilter
|
2020-08-17 09:16:52 +00:00
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
targets []Target
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 14:47:43 +00:00
|
|
|
// Table is a unified structure of EACLTable
|
|
|
|
// message from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type Table struct {
|
2020-09-04 07:50:36 +00:00
|
|
|
version *refs.Version
|
|
|
|
|
2020-08-17 09:16:52 +00:00
|
|
|
cid *refs.ContainerID
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
records []Record
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:07:35 +00:00
|
|
|
type TokenLifetime struct {
|
|
|
|
exp, nbf, iat uint64
|
|
|
|
}
|
|
|
|
|
2024-05-28 08:54:38 +00:00
|
|
|
type APEOverride struct {
|
|
|
|
target *ape.ChainTarget
|
|
|
|
|
|
|
|
chains []*ape.Chain
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:07:35 +00:00
|
|
|
type BearerTokenBody struct {
|
|
|
|
eacl *Table
|
|
|
|
|
|
|
|
ownerID *refs.OwnerID
|
|
|
|
|
|
|
|
lifetime *TokenLifetime
|
2023-02-21 08:23:08 +00:00
|
|
|
|
2024-05-28 08:54:38 +00:00
|
|
|
apeOverride *APEOverride
|
|
|
|
|
2023-02-21 08:23:08 +00:00
|
|
|
impersonate bool
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type BearerToken struct {
|
|
|
|
body *BearerTokenBody
|
|
|
|
|
|
|
|
sig *refs.Signature
|
|
|
|
}
|
|
|
|
|
2020-09-10 10:01:31 +00:00
|
|
|
// Target is a unified enum of MatchType enum from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type MatchType uint32
|
|
|
|
|
2020-08-17 14:47:43 +00:00
|
|
|
// HeaderType is a unified enum of HeaderType enum from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type HeaderType uint32
|
|
|
|
|
2020-08-17 14:47:43 +00:00
|
|
|
// Action is a unified enum of Action enum from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type Action uint32
|
|
|
|
|
2020-08-17 14:47:43 +00:00
|
|
|
// Operation is a unified enum of Operation enum from proto definition.
|
2020-08-17 09:16:52 +00:00
|
|
|
type Operation uint32
|
|
|
|
|
2020-09-04 07:50:36 +00:00
|
|
|
// Role is a unified enum of Role enum from proto definition.
|
|
|
|
type Role uint32
|
2020-08-17 09:16:52 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
MatchTypeUnknown MatchType = iota
|
|
|
|
MatchTypeStringEqual
|
|
|
|
MatchTypeStringNotEqual
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
HeaderTypeUnknown HeaderType = iota
|
|
|
|
HeaderTypeRequest
|
|
|
|
HeaderTypeObject
|
2021-09-14 10:51:20 +00:00
|
|
|
HeaderTypeService
|
2020-08-17 09:16:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
ActionUnknown Action = iota
|
|
|
|
ActionAllow
|
2020-08-17 13:32:46 +00:00
|
|
|
ActionDeny
|
2020-08-17 09:16:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
OperationUnknown Operation = iota
|
|
|
|
OperationGet
|
|
|
|
OperationHead
|
2020-08-17 13:32:46 +00:00
|
|
|
OperationPut
|
2020-08-17 09:16:52 +00:00
|
|
|
OperationDelete
|
|
|
|
OperationSearch
|
|
|
|
OperationRange
|
|
|
|
OperationRangeHash
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-09-04 07:50:36 +00:00
|
|
|
RoleUnknown Role = iota
|
|
|
|
RoleUser
|
|
|
|
RoleSystem
|
|
|
|
RoleOthers
|
2020-08-17 09:16:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (f *HeaderFilter) GetHeaderType() HeaderType {
|
|
|
|
if f != nil {
|
|
|
|
return f.hdrType
|
|
|
|
}
|
|
|
|
|
|
|
|
return HeaderTypeUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *HeaderFilter) SetHeaderType(v HeaderType) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.hdrType = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *HeaderFilter) GetMatchType() MatchType {
|
|
|
|
if f != nil {
|
|
|
|
return f.matchType
|
|
|
|
}
|
|
|
|
|
|
|
|
return MatchTypeUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *HeaderFilter) SetMatchType(v MatchType) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.matchType = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 13:55:19 +00:00
|
|
|
func (f *HeaderFilter) GetKey() string {
|
2020-08-17 09:16:52 +00:00
|
|
|
if f != nil {
|
2020-10-27 13:55:19 +00:00
|
|
|
return f.key
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-10-27 13:55:19 +00:00
|
|
|
func (f *HeaderFilter) SetKey(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.key = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *HeaderFilter) GetValue() string {
|
|
|
|
if f != nil {
|
|
|
|
return f.value
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *HeaderFilter) SetValue(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.value = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-10 10:01:31 +00:00
|
|
|
func (t *Target) GetRole() Role {
|
2020-08-17 09:16:52 +00:00
|
|
|
if t != nil {
|
2020-09-04 07:50:36 +00:00
|
|
|
return t.role
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 07:50:36 +00:00
|
|
|
return RoleUnknown
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-10 10:01:31 +00:00
|
|
|
func (t *Target) SetRole(v Role) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.role = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 12:39:13 +00:00
|
|
|
func (t *Target) GetKeys() [][]byte {
|
2020-08-17 09:16:52 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.keys
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-19 12:39:13 +00:00
|
|
|
func (t *Target) SetKeys(v [][]byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.keys = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Record) GetOperation() Operation {
|
|
|
|
if r != nil {
|
|
|
|
return r.op
|
|
|
|
}
|
|
|
|
|
|
|
|
return OperationUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Record) SetOperation(v Operation) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.op = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Record) GetAction() Action {
|
|
|
|
if r != nil {
|
|
|
|
return r.action
|
|
|
|
}
|
|
|
|
|
|
|
|
return ActionUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Record) SetAction(v Action) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.action = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
func (r *Record) GetFilters() []HeaderFilter {
|
2020-08-17 09:16:52 +00:00
|
|
|
if r != nil {
|
|
|
|
return r.filters
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
func (r *Record) SetFilters(v []HeaderFilter) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.filters = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
func (r *Record) GetTargets() []Target {
|
2020-08-17 09:16:52 +00:00
|
|
|
if r != nil {
|
|
|
|
return r.targets
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
func (r *Record) SetTargets(v []Target) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.targets = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 07:50:36 +00:00
|
|
|
func (t *Table) GetVersion() *refs.Version {
|
|
|
|
if t != nil {
|
|
|
|
return t.version
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Table) SetVersion(v *refs.Version) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.version = v
|
2020-09-04 07:50:36 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 09:16:52 +00:00
|
|
|
func (t *Table) GetContainerID() *refs.ContainerID {
|
|
|
|
if t != nil {
|
|
|
|
return t.cid
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Table) SetContainerID(v *refs.ContainerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.cid = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
func (t *Table) GetRecords() []Record {
|
2020-08-17 09:16:52 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.records
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:32:54 +00:00
|
|
|
func (t *Table) SetRecords(v []Record) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.records = v
|
2020-08-17 09:16:52 +00:00
|
|
|
}
|
2020-08-20 10:07:35 +00:00
|
|
|
|
|
|
|
func (l *TokenLifetime) GetExp() uint64 {
|
|
|
|
if l != nil {
|
|
|
|
return l.exp
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) SetExp(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.exp = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) GetNbf() uint64 {
|
|
|
|
if l != nil {
|
|
|
|
return l.nbf
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) SetNbf(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.nbf = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) GetIat() uint64 {
|
|
|
|
if l != nil {
|
|
|
|
return l.iat
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) SetIat(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.iat = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) GetEACL() *Table {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.eacl
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) SetEACL(v *Table) {
|
2022-03-23 11:42:57 +00:00
|
|
|
bt.eacl = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
2024-05-28 08:54:38 +00:00
|
|
|
func (t *APEOverride) GetTarget() *ape.ChainTarget {
|
2024-09-06 08:39:23 +00:00
|
|
|
if t == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-05-28 08:54:38 +00:00
|
|
|
return t.target
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *APEOverride) GetChains() []*ape.Chain {
|
2024-09-06 08:39:23 +00:00
|
|
|
if t == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-05-28 08:54:38 +00:00
|
|
|
return t.chains
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *APEOverride) SetTarget(v *ape.ChainTarget) {
|
|
|
|
t.target = v
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *APEOverride) SetChains(v []*ape.Chain) {
|
|
|
|
t.chains = v
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) GetAPEOverride() *APEOverride {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.apeOverride
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) SetAPEOverride(v *APEOverride) {
|
|
|
|
bt.apeOverride = v
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:07:35 +00:00
|
|
|
func (bt *BearerTokenBody) GetOwnerID() *refs.OwnerID {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.ownerID
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) SetOwnerID(v *refs.OwnerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
bt.ownerID = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) GetLifetime() *TokenLifetime {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.lifetime
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) SetLifetime(v *TokenLifetime) {
|
2022-03-23 11:42:57 +00:00
|
|
|
bt.lifetime = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 08:23:08 +00:00
|
|
|
func (bt *BearerTokenBody) GetImpersonate() bool {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.impersonate
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerTokenBody) SetImpersonate(v bool) {
|
|
|
|
bt.impersonate = v
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:07:35 +00:00
|
|
|
func (bt *BearerToken) GetBody() *BearerTokenBody {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerToken) SetBody(v *BearerTokenBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
bt.body = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerToken) GetSignature() *refs.Signature {
|
|
|
|
if bt != nil {
|
|
|
|
return bt.sig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bt *BearerToken) SetSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
bt.sig = v
|
2020-08-20 10:07:35 +00:00
|
|
|
}
|