forked from TrueCloudLab/frostfs-s3-gw
Add a stub for auth scheme
This commit is contained in:
parent
2fee7d2577
commit
88f0f9fcbe
1 changed files with 23 additions and 0 deletions
23
neofs/auth.go
Normal file
23
neofs/auth.go
Normal file
|
@ -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
|
||||||
|
}
|
Loading…
Reference in a new issue