Files
sam c5f4541cbf
Quality / check (push) Canceled after 1m5s
deploy / gate (push) Successful in 4m35s
deploy / archied-image (push) Successful in 2m49s
deploy / agent-image (push) Successful in 12s
deploy / dist-zip (push) Skipped
refactor(webui): extract the access policies and denials module (#1778)
2026-11-03 08:33:46 +11:00

35 lines
1015 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 (a *accessAPI) handleListDenials(w http.ResponseWriter, r *http.Request) {
if a.denials == 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 := a.denials.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})
}