forked from TrueCloudLab/frostfs-api-go
[#150] sdk/token: Add owner ID
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
73220620c5
commit
0259a06783
4 changed files with 104 additions and 34 deletions
|
@ -1034,6 +1034,8 @@ func (c Client) attachV2SessionToken(opts callOptions, hdr *v2session.RequestMet
|
|||
return nil
|
||||
}
|
||||
|
||||
token := opts.session.ToV2()
|
||||
|
||||
opCtx := new(v2session.ObjectSessionContext)
|
||||
opCtx.SetAddress(info.addr)
|
||||
opCtx.SetVerb(info.verb)
|
||||
|
@ -1043,15 +1045,11 @@ func (c Client) attachV2SessionToken(opts callOptions, hdr *v2session.RequestMet
|
|||
lt.SetNbf(info.nbf)
|
||||
lt.SetExp(info.exp)
|
||||
|
||||
body := new(v2session.SessionTokenBody)
|
||||
body.SetID(opts.session.ID())
|
||||
body := token.GetBody()
|
||||
body.SetSessionKey(opts.session.SessionKey())
|
||||
body.SetContext(opCtx)
|
||||
body.SetLifetime(lt)
|
||||
|
||||
token := new(v2session.SessionToken)
|
||||
token.SetBody(body)
|
||||
|
||||
signWrapper := signature.StableMarshalerWrapper{SM: token.GetBody()}
|
||||
err := signer.SignDataWithHandler(c.key, signWrapper, func(key []byte, sig []byte) {
|
||||
sessionTokenSignature := new(v2refs.Signature)
|
||||
|
|
|
@ -70,10 +70,10 @@ func (c Client) createSessionV2(ctx context.Context, expiration uint64, opts ...
|
|||
return nil, errors.New("malformed response body")
|
||||
}
|
||||
|
||||
sessionToken, err := token.CreateSessionToken(body.GetID(), body.GetSessionKey())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "malformed response body")
|
||||
}
|
||||
sessionToken := token.NewSessionToken()
|
||||
sessionToken.SetID(body.GetID())
|
||||
sessionToken.SetSessionKey(body.GetSessionKey())
|
||||
sessionToken.SetOwnerID(ownerID)
|
||||
|
||||
return sessionToken, nil
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue