[#66] Use gate key to form object owner

This is required because node check session token owner
TrueCloudLab/frostfs-node#528
For client cut TrueCloudLab/frostfs-sdk-go#114
such owner will be gate owner

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-08-07 12:08:34 +03:00
parent 97ac638dff
commit cc69601b32
2 changed files with 6 additions and 6 deletions

View file

@ -17,6 +17,7 @@ This document outlines major changes between releases.
- Update prometheus to v1.15.0 (#35) - Update prometheus to v1.15.0 (#35)
- Update go version to 1.19 (#50) - Update go version to 1.19 (#50)
- Finish rebranding (#2) - Finish rebranding (#2)
- Use gate key to form object owner (#66)
### Removed ### Removed
- Drop `tree.service` param (now endpoints from `peers` section are used) (#59) - Drop `tree.service` param (now endpoints from `peers` section are used) (#59)

View file

@ -145,17 +145,17 @@ func (u *Uploader) Upload(req *fasthttp.RequestCtx) {
timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10)) timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10))
attributes = append(attributes, *timestamp) attributes = append(attributes, *timestamp)
} }
id, bt := u.fetchOwnerAndBearerToken(ctx)
obj := object.New() obj := object.New()
obj.SetContainerID(*idCnr) obj.SetContainerID(*idCnr)
obj.SetOwnerID(id) obj.SetOwnerID(u.ownerID)
obj.SetAttributes(attributes...) obj.SetAttributes(attributes...)
var prm pool.PrmObjectPut var prm pool.PrmObjectPut
prm.SetHeader(*obj) prm.SetHeader(*obj)
prm.SetPayload(file) prm.SetPayload(file)
bt := u.fetchBearerToken(ctx)
if bt != nil { if bt != nil {
prm.UseBearer(*bt) prm.UseBearer(*bt)
} }
@ -200,12 +200,11 @@ func (u *Uploader) handlePutFrostFSErr(r *fasthttp.RequestCtx, err error) {
response.Error(r, msg, statusCode) response.Error(r, msg, statusCode)
} }
func (u *Uploader) fetchOwnerAndBearerToken(ctx context.Context) (*user.ID, *bearer.Token) { func (u *Uploader) fetchBearerToken(ctx context.Context) *bearer.Token {
if tkn, err := tokens.LoadBearerToken(ctx); err == nil && tkn != nil { if tkn, err := tokens.LoadBearerToken(ctx); err == nil && tkn != nil {
issuer := bearer.ResolveIssuer(*tkn) return tkn
return &issuer, tkn
} }
return u.ownerID, nil return nil
} }
type putResponse struct { type putResponse struct {