A self-hosted admission-control engine for anonymous services.
Project details
OnionGuard provides a robust solution for managing access to anonymous services. As an open-source engine designed for sovereignty and control, it empowers users to intelligently admit sessions in real time, enhancing security and ensuring privacy across critical applications.
OnionGuard is a robust open-source admission-control engine tailored specifically for anonymous services and Tor Onion Services. It operates on a production-grade, zero-trust model, ensuring secure HTTP request management without relying on traditional client-based mechanisms, which are ineffective in the context of Tor.
Traditional solutions like Cloudflare and AWS WAF falter when it comes to Tor networks due to:
OnionGuard is specifically designed to tackle these challenges by enforcing advanced access control measures, including:
OnionGuard’s architecture elegantly handles HTTP requests, utilizing middleware for secure processing:
┌─────────────────────────────────────────────┐
│ HTTP Requests (Tor / Clear) │
└──────────────────────┬──────────────────────┘
│
┌──────────────────────────────┴──────────────────────────────┐
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐
│ net/http Middleware │ │ Fiber v2 Submodule │
│ - onionguard/middleware │ │ - middleware/fiber │
└────────────┬─────────────┘ └────────────┬─────────────┘
└──────────────────────┬─────────────────────────────────┘
▼
┌──────────────────────────────┐
│ OnionGuard Engine │
│ - ResolveWithSession (1x) │
│ - AuthorizeRequest │
│ - EvaluateFresh │
└──────────────┬───────────────┘
│
┌────────────┬───────────────┼───────────────┬────────────┐
▼ ▼ ▼ ▼ ▼
Identity Session & Wait Room & Rate Limiter Security
Model Admission CAPTCHA Engine (Token Bucket) Headers
(4 Tiers) (7 States) (Zero-JS PNG) (Multi-Scope) (CSP, no-store)
The setup for OnionGuard is straightforward, with support for both the Go standard library and the Fiber v2 framework. Below is a minimal example:
package main
import (
"log"
"net/http"
"time"
og "github.com/ihatemyfcklife/onionguard"
"github.com/ihatemyfcklife/onionguard/middleware"
)
func main() {
cfg := og.DefaultConfig()
cfg.WaitRoom.Enabled = true
cfg.WaitRoom.WaitTime = 5 * time.Second
cfg.Captcha.Enabled = true
engine, err := og.New(cfg)
if err != nil {
log.Fatalf("failed to initialize onionguard: %v", err)
}
defer engine.Close()
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if id, ok := og.ClientIdentityFromContext(r.Context()); ok {
log.Printf("Admitted client: kind=%s, principal=%s", id.Kind, id.PrincipalID)
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Write([]byte("Access granted: Welcome to OnionGuard protected service!\n"))
})
handler := middleware.Middleware(engine)(mux)
srv := &http.Server{
Addr: ":8080",
Handler: handler,
ReadHeaderTimeout: 5 * time.Second,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
IdleTimeout: 60 * time.Second,
MaxHeaderBytes: 16 * 1024,
}
log.Printf("Server listening on http://localhost:8080")
log.Fatal(srv.ListenAndServe())
}
OnionGuard represents a significant advancement in managing admission controls for anonymous services. With its zero-trust architecture, it provides a secure, reliable, and efficient method of ensuring user access while preserving the anonymity and privacy essential to the Tor ecosystem. Its innovative features and sophisticated security measures make it an optimal choice for developers ready to deploy robust solutions in anonymous environments.
Comments
0Start the conversation
Share the first comment.