Documentation
¶
Overview ¶
Package caddyprotector provides a Cap-protected HTTP middleware module for Caddy.
Index ¶
- type CaddyProtector
- func (*CaddyProtector) CaddyModule() caddy.ModuleInfo
- func (bb *CaddyProtector) Cleanup() error
- func (bb *CaddyProtector) Provision(ctx caddy.Context) error
- func (bb *CaddyProtector) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (bb *CaddyProtector) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (bb *CaddyProtector) Validate() error
- type HeaderSubstringRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaddyProtector ¶
type CaddyProtector struct {
// TemplatePath is the path to a custom HTML template.
TemplatePath string `json:"template,omitempty"`
// DisableCSPHeader disables the CSP header set by CaddyProtector.
DisableCSPHeader bool `json:"disable_csp_header,omitempty"`
// AllowFor determines how long a successfully verified client remains allowed.
AllowFor caddy.Duration `json:"allow_for,omitempty"`
// VerifyPath is the internal POST endpoint for verification.
VerifyPath string `json:"verify_path,omitempty"`
// CapAPIURL is the public base URL of the Cap instance.
CapAPIURL string `json:"cap_api_url,omitempty"`
// CapSiteKey is the site key of the Cap instance.
CapSiteKey string `json:"cap_site_key,omitempty"`
// CapSecretKey is the secret key for server-side /siteverify requests.
CapSecretKey string `json:"cap_secret_key,omitempty"`
// CookieName is the name of the allow cookie.
CookieName string `json:"cookie_name,omitempty"`
// CookiePath is the path of the allow cookie.
CookiePath string `json:"cookie_path,omitempty"`
// CookieDomain optionally sets the domain of the allow cookie.
CookieDomain string `json:"cookie_domain,omitempty"`
// CookieSecure controls the Secure flag of the allow cookie.
CookieSecure *bool `json:"cookie_secure,omitempty"`
// CookieHTTPOnly controls the HttpOnly flag of the allow cookie.
CookieHTTPOnly *bool `json:"cookie_http_only,omitempty"`
// CookieSameSite controls the SameSite attribute of the allow cookie.
CookieSameSite string `json:"cookie_same_site,omitempty"`
// DenyPathPrefixes denies requests with matching path prefixes.
DenyPathPrefixes []string `json:"deny_path_prefix,omitempty"`
// DenyQuerySubstrings denies requests with matching query substrings.
DenyQuerySubstrings []string `json:"deny_query_substring,omitempty"`
// DenyHeaderSubstrings denies requests with matching header substrings.
DenyHeaderSubstrings []HeaderSubstringRule `json:"deny_header_substring,omitempty"`
// WhitelistIPs are IPs or CIDR prefixes allowed without a challenge.
WhitelistIPs []string `json:"whitelist_ip,omitempty"`
// WhitelistFile points to a file with IP or CIDR entries.
WhitelistFile string `json:"whitelist_file,omitempty"`
// WhitelistURL points to a URL with IP or CIDR entries.
WhitelistURL string `json:"whitelist_url,omitempty"`
// WhitelistRefresh determines the refresh interval for file and URL sources.
WhitelistRefresh caddy.Duration `json:"whitelist_refresh,omitempty"`
// WhitelistCountries limits requests to specific ISO-3166-1 alpha-2 countries.
WhitelistCountries []string `json:"whitelist_country,omitempty"`
// BlacklistIPs are IPs or CIDR prefixes denied immediately.
BlacklistIPs []string `json:"blacklist_ip,omitempty"`
// BlacklistFile points to a file with IP or CIDR entries.
BlacklistFile string `json:"blacklist_file,omitempty"`
// BlacklistURL points to a URL with IP or CIDR entries.
BlacklistURL string `json:"blacklist_url,omitempty"`
// BlacklistRefresh determines the refresh interval for file and URL sources.
BlacklistRefresh caddy.Duration `json:"blacklist_refresh,omitempty"`
// BlacklistCountries denies requests from specific ISO-3166-1 alpha-2 countries.
BlacklistCountries []string `json:"blacklist_country,omitempty"`
// CountryURL points to a MaxMind MMDB for country lookups.
CountryURL string `json:"country_url,omitempty"`
// CountryRefresh determines the refresh interval for the country MMDB.
CountryRefresh caddy.Duration `json:"country_url_refresh,omitempty"`
// contains filtered or unexported fields
}
CaddyProtector is a Caddy middleware module that protects requests with a preliminary Cap verification and sets a signed allow cookie after verification.
func (*CaddyProtector) CaddyModule ¶
func (*CaddyProtector) CaddyModule() caddy.ModuleInfo
CaddyModule beschreibt das Caddy-Modul und seine Instanziierung.
func (*CaddyProtector) Cleanup ¶
func (bb *CaddyProtector) Cleanup() error
Cleanup beendet alle Hintergrund-Refreshes und gibt die Country-Datenbank frei.
func (*CaddyProtector) Provision ¶
func (bb *CaddyProtector) Provision(ctx caddy.Context) error
Provision initialisiert das Modul, den Logger und die Standardwerte.
func (*CaddyProtector) ServeHTTP ¶
func (bb *CaddyProtector) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
ServeHTTP prüft den Challenge-Status oder liefert eine Challenge-Seite aus.
func (*CaddyProtector) UnmarshalCaddyfile ¶
func (bb *CaddyProtector) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile liest die Konfiguration aus dem Caddyfile.
func (*CaddyProtector) Validate ¶
func (bb *CaddyProtector) Validate() error
Validate prüft die Konfiguration.
type HeaderSubstringRule ¶
HeaderSubstringRule describes a header name and a substring to deny.