forked from TrueCloudLab/frostfs-node
[#57] services/object: Add session token to common parameters
Add session token field to CommonPrm. Remove session token field from Put parameters. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
39c17253be
commit
2da323c4b9
3 changed files with 25 additions and 14 deletions
|
@ -1,11 +1,14 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||
)
|
||||
|
||||
type CommonPrm struct {
|
||||
local bool
|
||||
|
||||
token *token.SessionToken
|
||||
}
|
||||
|
||||
func (p *CommonPrm) WithLocalOnly(v bool) *CommonPrm {
|
||||
|
@ -24,6 +27,22 @@ func (p *CommonPrm) LocalOnly() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (p *CommonPrm) WithSessionToken(token *token.SessionToken) *CommonPrm {
|
||||
if p != nil {
|
||||
p.token = token
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *CommonPrm) SessionToken() *token.SessionToken {
|
||||
if p != nil {
|
||||
return p.token
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CommonPrmFromV2(req interface {
|
||||
GetMetaHeader() *session.RequestMetaHeader
|
||||
}) *CommonPrm {
|
||||
|
@ -31,5 +50,6 @@ func CommonPrmFromV2(req interface {
|
|||
|
||||
return &CommonPrm{
|
||||
local: meta.GetTTL() <= 1, // FIXME: use constant
|
||||
token: token.NewSessionTokenFromV2(meta.GetSessionToken()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue