How jipok/jauth works
Project type and purpose
• Jauth is a single‐binary Go application that acts as an SSL/TLS reverse proxy with built-in user authorization (via SSH public keys or Telegram SSO). It protects self-hosted services by intercepting incoming HTTP/HTTPS connections, authenticating users, and forwarding traffic to backend targets.
File structure
• Top-level Go files (main.go, auth-handler.go, ssl-proxy.go, ssh-server.go, etc.) implement the core logic.
• config/ and config/dsl.go parse a TOML DSL for domains, certificate settings, SSH/Telegram users, whitelist rules.
• www/ holds static HTML pages (login, whitelist error, 502 fallback).
• Scripts (compact.sh, github-key-import.sh) automate key management or build steps.
• go.mod/go.sum define dependencies (net/http, crypto/tls, golang.org/x/crypto/ssh, autocert).
Key README insights
• On startup, Jauth loads a config (jauth.toml by default), then:
• Generates or acquires certificates (self-signed or via Let’s Encrypt autocert)
• Listens on port 80 (HTTP) to redirect to HTTPS, and port 443 (HTTPS) for protected resources
• Listens on port 2222 (SSH) to perform public-key authentication and mint session tokens
• Stores session tokens in jauth-tokens.txt, passes authenticated usernames via a Remote-User HTTP header
• For each request, enforces per-domain whitelist rules, then reverse-proxies to the configured target.
Detail
• Listeners, the cert-management pathway, both auth methods, the token lifecycle, and backend proxying.
• Per-domain rules: UserSuffix, Whitelist, NoAuth override
• Where drop-privileges and filtering (spam suppression) modules sit in the startup sequence