Documentation
¶
Index ¶
- Variables
- func Decrypt(jwt string, target any, keychain Keychain) error
- func Encrypt(object any, key PublicEncryptionKey, encryption jose.ContentEncryption) (string, error)
- func JWKFromEncryptionKey(key EncryptionKey) jose.JSONWebKey
- func JWKFromPrivateKey(key PrivateKey) jose.JSONWebKey
- func JWKFromSigningKey(key SigningKey) jose.JSONWebKey
- func JWKSFromKeys(key ...Key) jose.JSONWebKeySet
- func JWKSFromPublicKeychain(keychain PublicKeychain) jose.JSONWebKeySet
- func Sign(object any, key PrivateSigningKey) (string, error)
- func UnsafeDecodeSigned(jwt string, target any) error
- func Verify(jwt string, target any, keychain PublicKeychain) error
- type EncryptionKey
- type EncryptionKeychain
- type EncryptionKeypair
- type Key
- type Keychain
- type Keypair
- type PrivateEncryptionKey
- type PrivateKey
- type PrivateSigningKey
- type PublicEncryptionKey
- type PublicEncryptionKeychain
- type PublicKey
- type PublicKeychain
- type PublicSigningKey
- type PublicSigningKeychain
- type SigningKey
- type SigningKeychain
- type SigningKeypair
Constants ¶
This section is empty.
Variables ¶
var (
ErrKeyNotFound = errors.New("key not found in the keychain")
)
Functions ¶
func Decrypt ¶
Decrypt decrypts the encrypted JWT and deserializes the payload from JSON format. While decryption, it tries to parse the JWT header and finds an encryption key by their ID from the keychain. If no key found for the key ID, returns ErrKeyNotFound.
func Encrypt ¶
func Encrypt(object any, key PublicEncryptionKey, encryption jose.ContentEncryption) (string, error)
Encrypt encrypts the object and construct JWT using the encryption key after serializing into JSON format.
func JWKFromEncryptionKey ¶
func JWKFromEncryptionKey(key EncryptionKey) jose.JSONWebKey
func JWKFromPrivateKey ¶
func JWKFromPrivateKey(key PrivateKey) jose.JSONWebKey
func JWKFromSigningKey ¶
func JWKFromSigningKey(key SigningKey) jose.JSONWebKey
func JWKSFromKeys ¶
func JWKSFromKeys(key ...Key) jose.JSONWebKeySet
func JWKSFromPublicKeychain ¶
func JWKSFromPublicKeychain(keychain PublicKeychain) jose.JSONWebKeySet
func Sign ¶
func Sign(object any, key PrivateSigningKey) (string, error)
Sign signs the object and construct JWT using the signing key after serializing into JSON format.
func UnsafeDecodeSigned ¶
UnsafeDecodeSigned decodes the signed JWT and deserializes the payload from JSON format. THIS DOES NOT PERFORM ANY VERIFICATION FOR THE SIGNATURE; DO NOT TRUST THE DECODED CONTENT.
func Verify ¶
func Verify(jwt string, target any, keychain PublicKeychain) error
Verify verifies the signed JWT and deserializes the payload from JSON format. While verification, it tries to parse the JWT header and finds a public signing key by their ID from the keychain. If no key found for the key ID, returns ErrKeyNotFound.
Types ¶
type EncryptionKey ¶
type EncryptionKey interface { Key EncryptionKeyAlgorithm() jose.KeyAlgorithm }
type EncryptionKeychain ¶
type EncryptionKeychain interface { Keychain PublicEncryptionKeychain EncryptionKeypairs() []EncryptionKeypair EncryptionKeypair(id string) EncryptionKeypair PrivateEncryptionKeys() []PrivateEncryptionKey PrivateEncryptionKey(id string) PrivateEncryptionKey }
type EncryptionKeypair ¶
type EncryptionKeypair interface { PublicEncryptionKey PrivateEncryptionKey }
type Keychain ¶
type Keychain interface { PublicKeychain Keypairs() []Keypair Keypair(id string) Keypair PrivateKeys() []PrivateKey PrivateKey(id string) PrivateKey }
type Keypair ¶
type Keypair interface { PublicKey PrivateKey }
type PrivateEncryptionKey ¶
type PrivateEncryptionKey interface { EncryptionKey PrivateKey }
type PrivateKey ¶
type PrivateSigningKey ¶
type PrivateSigningKey interface { SigningKey PrivateKey() any }
type PublicEncryptionKey ¶
type PublicEncryptionKey interface { EncryptionKey PublicKey }
type PublicEncryptionKeychain ¶
type PublicEncryptionKeychain interface { PublicKeychain PublicEncryptionKeys() []PublicEncryptionKey PublicEncryptionKey(id string) PublicEncryptionKey }
type PublicKeychain ¶
type PublicSigningKey ¶
type PublicSigningKey interface { SigningKey PublicKey() any }
type PublicSigningKeychain ¶
type PublicSigningKeychain interface { PublicKeychain PublicSigningKeys() []PublicSigningKey PublicSigningKey(id string) PublicSigningKey }
type SigningKey ¶
type SigningKey interface { Key SigningAlgorithm() jose.SignatureAlgorithm }
type SigningKeychain ¶
type SigningKeychain interface { Keychain PublicSigningKeychain SigningKeypairs() []SigningKeypair SigningKeypair(id string) SigningKeypair PrivateSigningKeys() []PrivateSigningKey PrivateSigningKey(id string) PrivateSigningKey }
type SigningKeypair ¶
type SigningKeypair interface { PublicSigningKey PrivateSigningKey }