forked from TrueCloudLab/frostfs-node
[#1211] neofs-cli: Specify verb in object session token
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
ca17eb0eb4
commit
1b5cb2dfe2
1 changed files with 35 additions and 6 deletions
|
@ -321,17 +321,46 @@ func prepareSessionPrmWithOwner(
|
||||||
ni, err := internalclient.NetworkInfo(netInfoPrm)
|
ni, err := internalclient.NetworkInfo(netInfoPrm)
|
||||||
exitOnErr(cmd, errf("read network info: %w", err))
|
exitOnErr(cmd, errf("read network info: %w", err))
|
||||||
|
|
||||||
sessionPrm.SetExp(ni.NetworkInfo().CurrentEpoch() + sessionTokenLifetime)
|
cur := ni.NetworkInfo().CurrentEpoch()
|
||||||
|
exp := cur + sessionTokenLifetime
|
||||||
|
sessionPrm.SetExp(exp)
|
||||||
|
|
||||||
sessionRes, err := internalclient.CreateSession(sessionPrm)
|
sessionRes, err := internalclient.CreateSession(sessionPrm)
|
||||||
exitOnErr(cmd, errf("open session: %w", err))
|
exitOnErr(cmd, errf("open session: %w", err))
|
||||||
|
|
||||||
|
for i := range prms {
|
||||||
|
objectContext := session.NewObjectContext()
|
||||||
|
switch prms[i].(type) {
|
||||||
|
case *internalclient.GetObjectPrm:
|
||||||
|
objectContext.ForGet()
|
||||||
|
case *internalclient.HeadObjectPrm:
|
||||||
|
objectContext.ForHead()
|
||||||
|
case *internalclient.PutObjectPrm:
|
||||||
|
objectContext.ForPut()
|
||||||
|
case *internalclient.DeleteObjectPrm:
|
||||||
|
objectContext.ForDelete()
|
||||||
|
case *internalclient.SearchObjectsPrm:
|
||||||
|
objectContext.ForSearch()
|
||||||
|
case *internalclient.PayloadRangePrm:
|
||||||
|
objectContext.ForRange()
|
||||||
|
case *internalclient.HashPayloadRangesPrm:
|
||||||
|
objectContext.ForRangeHash()
|
||||||
|
default:
|
||||||
|
panic("invalid client parameter type")
|
||||||
|
}
|
||||||
|
|
||||||
tok := session.NewToken()
|
tok := session.NewToken()
|
||||||
tok.SetID(sessionRes.ID())
|
tok.SetID(sessionRes.ID())
|
||||||
tok.SetSessionKey(sessionRes.SessionKey())
|
tok.SetSessionKey(sessionRes.SessionKey())
|
||||||
tok.SetOwnerID(ownerID)
|
tok.SetOwnerID(ownerID)
|
||||||
|
tok.SetContext(objectContext)
|
||||||
|
tok.SetExp(exp)
|
||||||
|
tok.SetIat(cur)
|
||||||
|
tok.SetNbf(cur)
|
||||||
|
|
||||||
|
err = tok.Sign(key)
|
||||||
|
exitOnErr(cmd, errf("session token signing: %w", err))
|
||||||
|
|
||||||
for i := range prms {
|
|
||||||
prms[i].SetSessionToken(tok)
|
prms[i].SetSessionToken(tok)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue