Documentation ¶
Index ¶
- func GenerateSignedHMAC(data []byte, key *[32]byte) []byte
- func RandomBytes(n int) ([]byte, error)
- type HMACStrategy
- type SignedHMACStrategy
- func (c *SignedHMACStrategy) Generate() (string, string, error)
- func (c *SignedHMACStrategy) GetExpirationTime(token string) (time.Time, error)
- func (c *SignedHMACStrategy) Signature(token string) string
- func (c *SignedHMACStrategy) Valid(token string) bool
- func (c *SignedHMACStrategy) Validate(token string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSignedHMAC ¶ added in v1.0.4
func RandomBytes ¶ added in v0.4.0
RandomBytes returns n random bytes by reading from crypto/rand.Reader
Types ¶
type HMACStrategy ¶
type HMACStrategy struct { TokenEntropy int GlobalSecret []byte RotatedGlobalSecrets [][]byte sync.Mutex }
HMACStrategy is responsible for generating and validating challenges.
func (*HMACStrategy) Generate ¶
func (c *HMACStrategy) Generate() (string, string, error)
Generate generates a token and a matching signature or returns an error. This method implements rfc6819 Section 5.1.4.2.2: Use High Entropy for Secrets.
func (*HMACStrategy) Signature ¶
func (c *HMACStrategy) Signature(token string) string
func (*HMACStrategy) Validate ¶
func (c *HMACStrategy) Validate(token string) (err error)
Validate validates a token and returns its signature or an error if the token is not valid.
type SignedHMACStrategy ¶ added in v1.0.4
type SignedHMACStrategy struct { TokenEntropy int GlobalSecret []byte RotatedGlobalSecrets [][]byte PrivateKey *rsa.PrivateKey sync.Mutex }
HMACStrategy is responsible for generating and validating challenges.
func (*SignedHMACStrategy) Generate ¶ added in v1.0.4
func (c *SignedHMACStrategy) Generate() (string, string, error)
Generate generates a token and a matching signature or returns an error. This method implements rfc6819 Section 5.1.4.2.2: Use High Entropy for Secrets.
func (*SignedHMACStrategy) GetExpirationTime ¶ added in v1.0.4
func (c *SignedHMACStrategy) GetExpirationTime(token string) (time.Time, error)
GetExpirationTime - Get Expiration Time from Token in UTC
func (*SignedHMACStrategy) Signature ¶ added in v1.0.4
func (c *SignedHMACStrategy) Signature(token string) string
Signature - Return Signature Out of HmacToken
func (*SignedHMACStrategy) Valid ¶ added in v1.0.4
func (c *SignedHMACStrategy) Valid(token string) bool
Valid - Check for Expiry of HMAC Token
func (*SignedHMACStrategy) Validate ¶ added in v1.0.4
func (c *SignedHMACStrategy) Validate(token string) (err error)
Validate validates a token and returns its signature or an error if the token is not valid.