From 9424a67fb108de1e4e14b5d7dcc6587d1a2bb844 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 21 Feb 2023 11:29:14 +0300 Subject: [PATCH] [#XX] Add impersonate flag to bearer token Signed-off-by: Denis Kirillov --- bearer/bearer.go | 14 ++++++++++++++ go.mod | 2 ++ go.sum | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bearer/bearer.go b/bearer/bearer.go index 9fbd07e..3034f75 100644 --- a/bearer/bearer.go +++ b/bearer/bearer.go @@ -32,6 +32,8 @@ type Token struct { sigSet bool sig refs.Signature + + impersonate bool } // reads Token from the acl.BearerToken message. If checkFieldPresence is set, @@ -68,6 +70,8 @@ func (b *Token) readFromV2(m acl.BearerToken, checkFieldPresence bool) error { return errors.New("missing token lifetime") } + b.impersonate = body.GetImpersonate() + sig := m.GetSignature() if b.sigSet = sig != nil; sig != nil { b.sig = *sig @@ -112,6 +116,8 @@ func (b Token) fillBody() *acl.BearerTokenBody { body.SetLifetime(&lifetime) } + body.SetImpersonate(b.impersonate) + return &body } @@ -208,6 +214,14 @@ func (b Token) EACLTable() eacl.Table { return eacl.Table{} } +func (b *Token) SetImpersonate(v bool) { + b.impersonate = v +} + +func (b Token) Impersonate() bool { + return b.impersonate +} + // AssertContainer checks if the token is valid within the given container. // // Note: cnr is assumed to refer to the issuer's container, otherwise the check diff --git a/go.mod b/go.mod index 496865b..3030ea4 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,8 @@ require ( go.uber.org/zap v1.24.0 ) +replace github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68 => github.com/KirillovDenis/frostfs-api-go/v2 v2.11.2-0.20230221082308-ac00938fa447 + require ( github.com/TrueCloudLab/frostfs-crypto v0.5.0 // indirect github.com/TrueCloudLab/rfc6979 v0.3.0 // indirect diff --git a/go.sum b/go.sum index e0628e7..bb3921e 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ github.com/CityOfZion/neo-go v0.62.1-pre.0.20191114145240-e740fbe708f8/go.mod h1 github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig= github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I= github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA= -github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68 h1:mwZr15qCuIcWojIOmH6LILPohbWIkknZe9vhBRapmfQ= -github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68/go.mod h1:u3P6aL/NpAIY5IFRsJhmV+61Q3pJ3BkLENqySkf5zZQ= +github.com/KirillovDenis/frostfs-api-go/v2 v2.11.2-0.20230221082308-ac00938fa447 h1:8PH1Wdzdk96XwMQheflK9uS9lsSDtLaE9Wfr1sBq+Ng= +github.com/KirillovDenis/frostfs-api-go/v2 v2.11.2-0.20230221082308-ac00938fa447/go.mod h1:u3P6aL/NpAIY5IFRsJhmV+61Q3pJ3BkLENqySkf5zZQ= github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42 h1:P/gisZxTzJ9R3tuYDaQWe0tY6m1Zea3gzdPpNYK+NP4= github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42/go.mod h1:qmf648elr+FWBZH3hqND8KVrXMnqu/e0z48k+sX8C2s= github.com/TrueCloudLab/frostfs-crypto v0.5.0 h1:ZoLjixSkQv3j1EwZ1WJzMEJY2NR+9nO4Pd8WSyM/RRI=