-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hmac.go
36 lines (28 loc) · 971 Bytes
/
hmac.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package charon
import (
"context"
"crypto/sha512"
"hash"
"github.com/ory/fosite/token/hmac"
)
type hmacStrategyConfigurator struct {
Secret []byte
}
// GetGlobalSecret implements hmac.HMACStrategyConfigurator.
func (h *hmacStrategyConfigurator) GetGlobalSecret(_ context.Context) ([]byte, error) {
return h.Secret, nil
}
// GetHMACHasher implements hmac.HMACStrategyConfigurator.
func (h *hmacStrategyConfigurator) GetHMACHasher(_ context.Context) func() hash.Hash {
return sha512.New512_256
}
// GetRotatedGlobalSecrets implements hmac.HMACStrategyConfigurator.
func (h *hmacStrategyConfigurator) GetRotatedGlobalSecrets(_ context.Context) ([][]byte, error) {
// TODO: Support RotatedGlobalSecrets.
return nil, nil
}
// GetTokenEntropy implements hmac.HMACStrategyConfigurator.
func (h *hmacStrategyConfigurator) GetTokenEntropy(_ context.Context) int {
return 32 //nolint:gomnd
}
var _ hmac.HMACStrategyConfigurator = (*hmacStrategyConfigurator)(nil)