frostfs-s3-gw/creds/s3/secret.go
Roman Khimov dbe65ae602 creds: move credential management into s3 gate
Mostly taken from old SDK (abe47687cd11266f946cad57f07572cc10c67226), but
error handling adapted to eliminate pkg/errors and internal packages.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2021-05-25 23:00:19 +03:00

19 lines
377 B
Go

package s3
import (
"crypto/sha256"
"encoding/hex"
"github.com/nspcc-dev/neofs-api-go/pkg/token"
)
// SecretAccessKey returns secret access key generated by BearerToken.
func SecretAccessKey(tkn *token.BearerToken) (string, error) {
data, err := tkn.Marshal()
if err != nil {
return "", err
}
hash := sha256.Sum256(data)
return hex.EncodeToString(hash[:]), nil
}