- add an outcome column and migration so allowed and denied decisions share one audit trail - fail closed when an allowed decision cannot be recorded - expose outcome filtering in the API and dashboard Route chat through the recording authorizer so its decisions are audited too.
17 lines
954 B
SQL
17 lines
954 B
SQL
-- +goose Up
|
|
-- The table that held refusals now holds every authorization decision. A row
|
|
-- records one outcome, coalesced per minute with identical requests, so rows
|
|
-- that exist already are refusals.
|
|
ALTER TABLE governance.access_denials
|
|
ADD COLUMN outcome text NOT NULL DEFAULT 'denied' CHECK (outcome IN ('allowed', 'denied'));
|
|
DROP INDEX governance.idx_governance_access_denials_dedup;
|
|
CREATE UNIQUE INDEX idx_governance_access_denials_dedup
|
|
ON governance.access_denials (org_id, principal, action, resource_kind, resource_id, outcome, level, policies, minute_at);
|
|
|
|
-- +goose Down
|
|
DELETE FROM governance.access_denials WHERE outcome = 'allowed';
|
|
DROP INDEX governance.idx_governance_access_denials_dedup;
|
|
CREATE UNIQUE INDEX idx_governance_access_denials_dedup
|
|
ON governance.access_denials (org_id, principal, action, resource_kind, resource_id, level, policies, minute_at);
|
|
ALTER TABLE governance.access_denials DROP COLUMN outcome;
|