Documentation ¶
Index ¶
- func CheckPasswordHash(password, hash string) bool
- func HashPassword(password string) (string, error)
- func LoadJwkSetFromFile(jwkSetFile string) (jwk.Set, error)
- func MustHashPassword(pw string) string
- func ParseJwkSet(jwkSetData []byte) (jwk.Set, error)
- func ParseSigningKeyFromPEMData(keyData []byte) (*rsa.PrivateKey, error)
- func ParseSigningKeyFromPEMFile(path string) (*rsa.PrivateKey, error)
- func ToJwks(pub *rsa.PublicKey) (jwk.Set, error)
- func ToJwksJSON(pub *rsa.PublicKey) ([]byte, error)
- func ToPEM(key *rsa.PrivateKey) []byte
- type Authenticator
- type Claims
- type JWK
- type KeyConfig
- type RSAKeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash compares a password against its hash
func HashPassword ¶
HashPassword creates a cryptograhic hash of a password
func LoadJwkSetFromFile ¶
LoadJwkSetFromFile ...
func MustHashPassword ¶
MustHashPassword creates a cryptographic hash of a password or panics
func ParseSigningKeyFromPEMData ¶
func ParseSigningKeyFromPEMData(keyData []byte) (*rsa.PrivateKey, error)
ParseSigningKeyFromPEMData parses a private RSA signing key from PEM data
func ParseSigningKeyFromPEMFile ¶
func ParseSigningKeyFromPEMFile(path string) (*rsa.PrivateKey, error)
ParseSigningKeyFromPEMFile parses a private RSA signing key from a PEM file
func ToJwksJSON ¶
ToJwksJSON converts a RSA public key to a JSON encoded JWK set
func ToPEM ¶
func ToPEM(key *rsa.PrivateKey) []byte
ToPEM converts a RSA private key into PEM format
Types ¶
type Authenticator ¶
type Authenticator struct { Issuer string Audience string ExpiresAfter time.Duration SignKey *rsa.PrivateKey JwkSet jwk.Set }
Authenticator provides convenient methods for signing and validating JWT claims
func (*Authenticator) SetupKeys ¶
func (auth *Authenticator) SetupKeys(config *KeyConfig) error
SetupKeys loads or generates keys from the config
func (*Authenticator) SignJwtClaims ¶
func (auth *Authenticator) SignJwtClaims(claims Claims) (string, error)
SignJwtClaims signs JWT claims using RS256 and returns the token string
type Claims ¶
type Claims interface {
jwt.Claims
GetRegisteredClaims() *jwt.RegisteredClaims
}
Claims defines the interface that custom JWT claim types must implement
type JWK ¶
type JWK struct { KID string `json:"kid"` Algorithm string `json:"alg"` E string `json:"e"` KTY string `json:"kty"` N string `json:"n"` }
JWK encodes a JSON web key
type KeyConfig ¶ added in v0.0.14
KeyConfig configures the keys that will be used for authentication
type RSAKeyPair ¶
type RSAKeyPair struct { PrivateKey *rsa.PrivateKey PublicKey *rsa.PublicKey }
RSAKeyPair is an RSA key pair
func GenerateRSAKeyPair ¶
func GenerateRSAKeyPair() (*RSAKeyPair, error)
GenerateRSAKeyPair generates an RSA key pair