Overview
The Anubis package provides the core Server implementation for bot detection and challenge management. Uselib.New() to create a new server instance, and lib.LoadPoliciesOrDefault() to load policy configurations.
Functions
New
Creates a new Anubis server instance with the specified options.Options
required
Server configuration options
*Server
Configured Anubis server instance
error
Error if server creation fails
LoadPoliciesOrDefault
Loads policy configuration from a file or uses the built-in default policies.context.Context
required
Context for loading policies (may include Thoth client)
string
Path to policy YAML file. If empty, uses built-in default policies
int
required
Default proof-of-work difficulty level (0-64, recommended: 15-25)
string
required
Log level: “debug”, “info”, “warn”, or “error”
*policy.ParsedConfig
Parsed and validated policy configuration
error
Error if policy loading or validation fails
Server Type
The Server type implementshttp.Handler and manages bot detection, challenge issuance, and request validation.
Server Methods
ServeHTTP
Implements the http.Handler interface. Routes requests to static assets, API endpoints, or the validation middleware.- Static assets (
.within.website/static/*) are served directly - API endpoints (
.within.website/api/*) handle challenges and validation - All other requests go through the bot detection and challenge flow
- Validated requests with valid JWT cookies are proxied to the upstream handler
MakeChallenge
API endpoint that issues a new challenge for client-side solving. Only available in development builds.redir(query string): Redirect URL after challenge completion
lib/anubis.go:361-432
PassChallenge
API endpoint that validates a completed challenge and issues a JWT cookie upon success.redir(query string, required): Redirect URL after successful validationid(query string, required): Challenge ID- Challenge-specific validation parameters (varies by algorithm)
- On success: HTTP 302 redirect with JWT cookie set
- On failure: Error page with details
- Validates redirect domain against
RedirectDomainswhitelist - Prevents double-spend attacks (challenges can only be solved once)
- Binds JWT to HTTP header if
JWTRestrictionHeaderis set
lib/anubis.go:434-585
HTTP Endpoints
Anubis registers the following endpoints (all prefixed withBasePrefix, default /.within.website):