forked from TrueCloudLab/frostfs-api-go
[#169] sdk/client: Do not resign session token
In some cases SDK Client provided with signed and prepared session token. In this case we don't need to change verb or sign it. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
d3e3889425
commit
7b3736567c
2 changed files with 16 additions and 1 deletions
|
@ -1006,7 +1006,14 @@ func (c Client) attachV2SessionToken(opts callOptions, hdr *v2session.RequestMet
|
|||
return nil
|
||||
}
|
||||
|
||||
token := opts.session.ToV2()
|
||||
// Do not resign already prepared session token
|
||||
if opts.session.Signature() != nil {
|
||||
hdr.SetSessionToken(opts.session.ToV2())
|
||||
return nil
|
||||
}
|
||||
|
||||
token := new(v2session.SessionToken)
|
||||
token.SetBody(opts.session.ToV2().GetBody())
|
||||
|
||||
opCtx := new(v2session.ObjectSessionContext)
|
||||
opCtx.SetAddress(info.addr)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package token
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||
)
|
||||
|
@ -68,3 +69,10 @@ func (t *SessionToken) SetSessionKey(v []byte) {
|
|||
body.SetSessionKey(v)
|
||||
})
|
||||
}
|
||||
|
||||
func (t *SessionToken) Signature() *pkg.Signature {
|
||||
return pkg.NewSignatureFromV2(
|
||||
(*session.SessionToken)(t).
|
||||
GetSignature(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue