From 88f0f9fcbe09f16bd25b5f4f2ec9c0c41c4f8216 Mon Sep 17 00:00:00 2001 From: Pavel Korotkov Date: Tue, 7 Jul 2020 10:08:58 +0300 Subject: [PATCH] Add a stub for auth scheme --- neofs/auth.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 neofs/auth.go diff --git a/neofs/auth.go b/neofs/auth.go new file mode 100644 index 000000000..bd9f388e1 --- /dev/null +++ b/neofs/auth.go @@ -0,0 +1,23 @@ +package neofs + +import ( + br "github.com/google/brotli/go/cbrotli" + "github.com/nspcc-dev/neofs-api-go/service" + "github.com/pkg/errors" +) + +func UnpackBearerToken(packedCredentials []byte) (service.BearerToken, error) { + // secretHash := packedCredentials[:32] + _ = packedCredentials[:32] + compressedKeyID := packedCredentials[32:] + keyID, err := br.Decode(compressedKeyID) + if err != nil { + return nil, errors.Wrap(err, "failed to decompress key ID") + } + bearerToken := new(service.BearerTokenMsg) + if err = bearerToken.Unmarshal(keyID); err != nil { + return nil, errors.Wrap(err, "failed to unmarshal embedded bearer token") + } + // TODO + return bearerToken, nil +}