Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigDefault = Config{ Next: nil, Except: nil, Key: nil, Encryptor: EncryptCookie, Decryptor: DecryptCookie, EncryptKeys: false, EncryptValues: true, SuppressErrors: false, SkipUnencryptedCookies: false, }
ConfigDefault is the default config
Functions ¶
func DecryptCookie ¶
DecryptCookie Decrypts a cookie data with specific encryption key
func EncryptCookie ¶
EncryptCookie Encrypts a cookie data with specific encryption key
func GenerateKey ¶
GenerateKey Generates an encryption key according to the length. If the length does not match the valid AES block size, it generates a 32-byte encryption key instead.
Types ¶
type Config ¶
type Config struct {
// Array of cookie keys that should not be encrypted.
//
// Optional. Default: nil
Except []string
// Unique key to encode & decode cookies.
//
// Required. Key length should be 16, 24, or 32 characters.
// You may use `encryptcookie.GenerateKey()` to generate a new key.
Key []byte
// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
// Custom function to encrypt cookies.
//
// Optional. Default: EncryptCookie
Encryptor func(message, key []byte) ([]byte, error)
// Custom function to decrypt cookies.
//
// Optional. Default: DecryptCookie
Decryptor func(ciphertext, key []byte) ([]byte, error)
// Encrypt cookie keys.
//
// Optional. Default: false
EncryptKeys bool
// Encrypt cookie values.
//
// Optional. Default: true
EncryptValues bool
// Suppress errors instead of panic on errors.
//
// Optional. Default: false
SuppressErrors bool
// Skip received cookies which are not encrypted.
//
// Optional. Default: false
SkipUnencryptedCookies bool
// contains filtered or unexported fields
}
Config defines the config for middleware.
Click to show internal directories.
Click to hide internal directories.