From cc69601b32a09290dae3ccdeab4eb39515251172 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 7 Aug 2023 12:08:34 +0300 Subject: [PATCH] [#66] Use gate key to form object owner This is required because node check session token owner https://git.frostfs.info/TrueCloudLab/frostfs-node/pulls/528 For client cut https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/issues/114 such owner will be gate owner Signed-off-by: Denis Kirillov --- CHANGELOG.md | 1 + uploader/upload.go | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48463c1..d323c89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This document outlines major changes between releases. - Update prometheus to v1.15.0 (#35) - Update go version to 1.19 (#50) - Finish rebranding (#2) +- Use gate key to form object owner (#66) ### Removed - Drop `tree.service` param (now endpoints from `peers` section are used) (#59) diff --git a/uploader/upload.go b/uploader/upload.go index 43996ea..57e426d 100644 --- a/uploader/upload.go +++ b/uploader/upload.go @@ -145,17 +145,17 @@ func (u *Uploader) Upload(req *fasthttp.RequestCtx) { timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10)) attributes = append(attributes, *timestamp) } - id, bt := u.fetchOwnerAndBearerToken(ctx) obj := object.New() obj.SetContainerID(*idCnr) - obj.SetOwnerID(id) + obj.SetOwnerID(u.ownerID) obj.SetAttributes(attributes...) var prm pool.PrmObjectPut prm.SetHeader(*obj) prm.SetPayload(file) + bt := u.fetchBearerToken(ctx) if bt != nil { prm.UseBearer(*bt) } @@ -200,12 +200,11 @@ func (u *Uploader) handlePutFrostFSErr(r *fasthttp.RequestCtx, err error) { 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 { - issuer := bearer.ResolveIssuer(*tkn) - return &issuer, tkn + return tkn } - return u.ownerID, nil + return nil } type putResponse struct {