fix(webui): instance health, logs, config and identities are system-org only

This commit is contained in:
sam committed 2026-10-10 20:20:07 +11:00
1 parent cef34ec438
commit a74b5955de
4 files changed
+93 -14

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
package webui
import (
"net/http"
"github.com/samcharles93/archie-core/internal/domain/access"
"github.com/samcharles93/archie-core/internal/domain/org"
)
// instanceViewer reports whether r may see instance-wide detail: process
// health, service logs, the loaded config and every identity on the instance.
// Only the system org operates the instance; a request with no principal is
// an install without the access chain, whose single operator is that org.
func instanceViewer(r *http.Request) bool {
p, ok := access.PrincipalFromContext(r.Context())
return !ok || p.Org == org.DefaultOrgID
}
// instanceOnly serves h to instance viewers and answers not found to anyone
// else, so another org learns nothing about the instance.
func instanceOnly(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !instanceViewer(r) {
http.NotFound(w, r)
return
}
h(w, r)
}
}