Files
archie/internal/webui/api_access_denials.go
T
sam da01f2cbe1 feat(access): denial retention knob, State Store sweep and dashboard denials page (#1842)
Add [access].denial_retention (default 90 days, matching the audit-retention
seed) wired through config defaults and validation; the State Store sweeps
denial records older than the configured age hourly via the new
access.DenialPruner / PruneDenials store query. The dashboard gains
GET /api/access/denials (read_audit-gated, so org admins/owners see their
org's records; the store scopes by the credential's org) and an
/org/denials page backed by a Pinia store.
2026-10-31 14:23:31 +11:00

35 lines
1022 B
Go

package webui
import (
"net/http"
"strconv"
"github.com/samcharles93/archie-core/internal/domain/access"
)
const defaultDenialsListLimit = 100
// handleListDenials lists the caller's org's recorded access denials, newest
// first. The route's read_audit grant limits it to the org's admins and
// owners, and the store scopes the list by the credential's org, so no
// request field chooses the org an operator reads.
func (s *Server) handleListDenials(w http.ResponseWriter, r *http.Request) {
if s.DenialLister == nil {
http.Error(w, "denial records unavailable", http.StatusServiceUnavailable)
return
}
limit, err := strconv.ParseInt(r.URL.Query().Get("limit"), 10, 32)
if err != nil || limit <= 0 || limit > 1000 {
limit = defaultDenialsListLimit
}
denials, err := s.DenialLister.ListDenials(r.Context(), policyOrg(r), int(limit))
if err != nil {
writeControlPlaneError(w, err)
return
}
if denials == nil {
denials = []access.Denial{}
}
writeJSON(w, map[string]any{"denials": denials})
}