forked from TrueCloudLab/frostfs-s3-gw
20 lines
377 B
Go
20 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
|
||
|
}
|