Serve DHCP on LANs plugged in after boot; accept browser logins
Kea skips interfaces without carrier when it opens its sockets and only looks again on a reload, so a LAN cable plugged in after Kea started got no DHCP until a restart. networkd-dispatcher now restarts Kea when a DHCP LAN gets carrier (a restart: a SIGHUP while Kea is starting ends it). The rule script is the same for every configuration and reads the interfaces from /etc/router/dhcp-interfaces, so the device never has to rebuild it (writeShellApplication's shellcheck could not be built offline). The web UI refused every login from a browser with "forbidden": under Referrer-Policy no-referrer browsers send "Origin: null" with form posts. Use http.CrossOriginProtection (Sec-Fetch-Site, then Origin) and a same-origin referrer policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
This commit is contained in:
@@ -189,7 +189,8 @@ func securityHeaders(next http.Handler) http.Handler {
|
||||
h := w.Header()
|
||||
h.Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'")
|
||||
h.Set("X-Content-Type-Options", "nosniff")
|
||||
h.Set("Referrer-Policy", "no-referrer")
|
||||
// Not no-referrer: under it browsers send "Origin: null" with form posts.
|
||||
h.Set("Referrer-Policy", "same-origin")
|
||||
h.Set("Cache-Control", "no-store")
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
@@ -237,13 +238,12 @@ func (a *app) auth(h func(http.ResponseWriter, *http.Request, session)) http.Han
|
||||
}
|
||||
}
|
||||
|
||||
// Sec-Fetch-Site first (browsers may send "Origin: null" for same-origin
|
||||
// form posts), then Origin; requests with neither (curl) pass.
|
||||
var crossOrigin = http.NewCrossOriginProtection()
|
||||
|
||||
func sameOrigin(r *http.Request) bool {
|
||||
origin := r.Header.Get("Origin")
|
||||
if origin == "" {
|
||||
return true
|
||||
}
|
||||
u, err := url.Parse(origin)
|
||||
return err == nil && u.Host == r.Host
|
||||
return crossOrigin.Check(r) == nil
|
||||
}
|
||||
|
||||
func (a *app) loginPage(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user