forked from TrueCloudLab/frostfs-rest-gw
[#32] Add route to form full binary bearer token
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
ada5bf5f9f
commit
07786dd94b
12 changed files with 703 additions and 5 deletions
|
@ -102,6 +102,21 @@ func (a *API) PostAuth(params operations.AuthParams) middleware.Responder {
|
|||
WithAccessControlAllowOrigin("*")
|
||||
}
|
||||
|
||||
// FormBinaryBearer handler that forms binary bearer token using headers with body and signature.
|
||||
func (a *API) FormBinaryBearer(params operations.FormBinaryBearerParams, principal *models.Principal) middleware.Responder {
|
||||
btoken, err := getBearerToken(principal, params.XBearerSignature, params.XBearerSignatureKey, *params.WalletConnect)
|
||||
if err != nil {
|
||||
resp := a.logAndGetErrorResponse("invalid bearer token", err)
|
||||
return operations.NewFormBinaryBearerBadRequest().WithPayload(resp)
|
||||
}
|
||||
|
||||
resp := &models.BinaryBearer{
|
||||
Token: util.NewString(base64.StdEncoding.EncodeToString(btoken.Marshal())),
|
||||
}
|
||||
|
||||
return operations.NewFormBinaryBearerOK().WithPayload(resp)
|
||||
}
|
||||
|
||||
func prepareObjectToken(ctx context.Context, params objectTokenParams, pool *pool.Pool, owner user.ID) (*models.TokenResponse, error) {
|
||||
btoken, err := util.ToNativeObjectToken(params.Records)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue