Clearly indicate insecure mode at startup.

This commit is contained in:
Catherine
2025-09-19 00:29:03 +00:00
parent 6a67785e02
commit 512d5e928a
2 changed files with 10 additions and 2 deletions

View File

@@ -31,6 +31,10 @@ func IsUnauthorized(err error) bool {
return false
}
func InsecureMode() bool {
return os.Getenv("INSECURE") == "very"
}
func GetHost(r *http.Request) string {
// FIXME: handle IDNA
host, _, err := net.SplitHostPort(r.Host)
@@ -180,7 +184,7 @@ func authorizeWildcardMatch(r *http.Request) ([]string, error) {
func authorizeRequest(r *http.Request, allowWildcard bool) ([]string, error) {
causes := []error{AuthError{http.StatusUnauthorized, "unauthorized"}}
if os.Getenv("INSECURE") == "very" {
if InsecureMode() {
log.Println("auth: INSECURE mode: allow any")
return nil, nil // for testing only
}

View File

@@ -100,7 +100,11 @@ func main() {
memlimit.WithRatio(0.9),
)
log.Println("ready")
if InsecureMode() {
log.Println("ready (INSECURE)")
} else {
log.Println("ready")
}
go serveHandler("pages", config.Listen.Pages, ServePages)