Documentation
¶
Index ¶
- func ParseRSAPrivateKey(keyData []byte, passphrase ...[]byte) (*rsa.PrivateKey, error)
- func SignJWT(alg JWTAlgorithm, key *rsa.PrivateKey, claims interface{}, ...) (string, error)
- func SignRS256(key *rsa.PrivateKey, claims interface{}, headerFields ...map[string]string) (string, error)
- func SignRS512(key *rsa.PrivateKey, claims interface{}, headerFields ...map[string]string) (string, error)
- type JWK
- type JWTAlgorithm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(keyData []byte, passphrase ...[]byte) (*rsa.PrivateKey, error)
ParseRSAPrivateKey auto-detects JWK (JSON) vs PEM/PKCS8 format and parses the RSA private key. Optional passphrase for encrypted PKCS8 keys.
func SignJWT ¶
func SignJWT(alg JWTAlgorithm, key *rsa.PrivateKey, claims interface{}, headerFields ...map[string]string) (string, error)
SignJWT creates a signed JWT token (header.payload.signature) using the specified algorithm (RS256 or RS512). Claims can be map[string]interface{} or a struct. Optional headerFields adds custom JWT header fields (e.g. "kid", "type").
Types ¶
type JWK ¶
type JWK struct {
KeyType string `json:"kty"`
Use string `json:"use,omitempty"`
KeyOps []string `json:"key_ops,omitempty"`
Algorithm string `json:"alg,omitempty"`
KeyID string `json:"kid,omitempty"`
PrivateKey *rsa.PrivateKey
}
JWK represents a parsed JSON Web Key with all standard attributes (RFC 7517).
type JWTAlgorithm ¶
type JWTAlgorithm string
JWT signing algorithm.
const ( RS256 JWTAlgorithm = "RS256" RS512 JWTAlgorithm = "RS512" )
Click to show internal directories.
Click to hide internal directories.