Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cookiecrypt.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package cookiecrypt provides Caddy HTTP middleware that encrypts cookies
// in transit.
package cookiecrypt

import (
Expand All @@ -24,13 +26,13 @@ type Cookiecrypt struct {
// Prefix marks encrypted cookie names (default "cc_" when omitted) and is
// a reserved namespace. Explicitly empty enables no-prefix mode: every
// inbound cookie is presumed ciphertext, and bare cookies are dropped
// unless they match AllowInbound or AllowOutbound.
// unless they match allow_inbound or allow_outbound.
Prefix *string `json:"prefix,omitempty"`
// BlockUnencrypted drops bare (unencrypted) client cookies unless their
// name matches AllowInbound.
// name matches allow_inbound.
BlockUnencrypted bool `json:"block_unencrypted,omitempty"`
// AllowInbound exempts bare client cookies from BlockUnencrypted
// (path.Match globs, "!" negates). Names matching AllowOutbound are
// AllowInbound exempts bare client cookies from block_unencrypted
// (path.Match globs, "!" negates). Names matching allow_outbound are
// accepted automatically.
AllowInbound []string `json:"allow_inbound,omitempty"`
// AllowOutbound cookies are passed through verbatim on responses instead
Expand Down
6 changes: 5 additions & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package cookiecrypt
import "errors"

var (
ErrInvalidKey = errors.New("invalid key")
// ErrInvalidKey reports a configured key that is not 64 hex characters
// decoding to 32 bytes.
ErrInvalidKey = errors.New("invalid key")
// ErrInvalidCiphertext reports a cookie value that could not be
// authenticated and decrypted with any configured key.
ErrInvalidCiphertext = errors.New("invalid ciphertext")
)
Loading