[#144] sdk/client: Add call option to set session token

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-09-15 13:51:36 +03:00 committed by Stanislav Bogatyrev
parent 3783133173
commit 5fa271e141
2 changed files with 109 additions and 7 deletions

View file

@ -2,9 +2,11 @@ package client
import (
"github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/token"
v2accounting "github.com/nspcc-dev/neofs-api-go/v2/accounting"
v2container "github.com/nspcc-dev/neofs-api-go/v2/container"
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
v2session "github.com/nspcc-dev/neofs-api-go/v2/session"
"google.golang.org/grpc"
)
@ -27,7 +29,7 @@ type (
xHeaders []xHeader
ttl uint32
epoch uint64
// add session token
session *token.SessionToken
// add bearer token
}
@ -45,6 +47,13 @@ type (
objectClientV2 *v2object.Client
}
v2SessionReqInfo struct {
addr *refs.Address
verb v2session.ObjectSessionVerb
exp, nbf, iat uint64
}
)
func defaultCallOptions() callOptions {
@ -92,6 +101,12 @@ func WithEpoch(epoch uint64) CallOption {
})
}
func WithSession(token *token.SessionToken) CallOption {
return newFuncCallOption(func(option *callOptions) {
option.session = token
})
}
func v2MetaHeaderFromOpts(options callOptions) *v2session.RequestMetaHeader {
meta := new(v2session.RequestMetaHeader)
meta.SetVersion(options.version.ToV2())