Skip /js/ in the Access Gate and set denied-page CSP so Denied UI can render.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Konrad Neitzel
2026-08-28 12:39:47 +02:00
co-authored by Cursor
parent 198ef0e204
commit 984b0c2335
7 changed files with 134 additions and 7 deletions
+25
View File
@@ -168,6 +168,31 @@ func TestAccessGateDeniesNonMemberWithHTML(t *testing.T) {
if !strings.Contains(rec.Body.String(), "Access denied") {
t.Fatalf("body=%q", rec.Body.String())
}
csp := rec.Header().Get("Content-Security-Policy")
if !strings.Contains(csp, "frame-ancestors 'self'") {
t.Fatalf("csp=%q", csp)
}
}
func TestAccessGateSkipsTopMenuScriptPrefix(t *testing.T) {
gate := gonexapp.AccessGate{Groups: []string{"dns-ops"}}
h := gate.Wrap(okInner())
for _, path := range []string{"/js/checkdns-main.js", "/js/app.js", "/js"} {
req := httptest.NewRequest(http.MethodGet, path, nil)
rec := httptest.NewRecorder()
h.ServeHTTP(rec, req)
if rec.Code != http.StatusOK || rec.Body.String() != "ok" {
t.Fatalf("%s: got %d %q", path, rec.Code, rec.Body.String())
}
}
req := httptest.NewRequest(http.MethodGet, "/json", nil)
rec := httptest.NewRecorder()
h.ServeHTTP(rec, req)
if rec.Code != http.StatusUnauthorized {
t.Fatalf("/json should stay gated, got %d", rec.Code)
}
}
func TestAccessGateLookupFailureServiceUnavailable(t *testing.T) {