Compliance
Compliance gives operators security, RBAC, audit-log, and retention views without mixing them into unrelated modules.
On this page
Where to look
| Area | Maintainer reference |
|---|---|
| Routes | Implementation referencesrc/app/(dashboard)/admin/security, src/app/(dashboard)/admin/audit-log |
| Security overview | Implementation referencesrc/features/compliance/server/security/queries.ts |
| Permission matrix | Implementation referencesrc/features/compliance/server/permissions/matrix-query.ts |
| Audit | Implementation referencesrc/features/compliance/server/audit/query.ts, redaction.ts, descriptions.ts, values.ts |
| Retention | Implementation referencesrc/features/compliance/server/retention/service.ts |
| Shared | Implementation referencesrc/features/compliance/shared/types.ts, formatters.ts |
| UI | Implementation referencesrc/features/compliance/ui/security-dashboard.tsx, audit-log-client.tsx |
Implementation reference3 areas
These Product code locations explain how the documented behavior is implemented. Expand them when you are ready to customize or maintain this area.
Security and audit surfaces
Admin pages render security overview, permission matrix, audit log, and retention status.
src/app/(dashboard)/admin/security/page.tsxsrc/app/(dashboard)/admin/audit-log/page.tsxsrc/features/compliance/ui/security-dashboard.tsxsrc/features/compliance/ui/audit-log-client.tsx
Compliance reads
Security, permission, and audit queries keep admin reporting server-owned and role-aware.
src/features/compliance/server/security/queries.tssrc/features/compliance/server/permissions/matrix-query.tssrc/features/compliance/server/audit/query.ts
Redaction and retention
Audit redaction and retention services preserve useful context without exposing sensitive payloads.
src/features/compliance/server/audit/redaction.tssrc/features/compliance/server/audit/descriptions.tssrc/features/compliance/server/retention/service.ts
Reference paths are relative to the Shipflash-Product checkout.
Compliance reporting flow
- 1
Gate admin routes
Security and audit surfaces should only render after server-side access checks.
Relevant Product code
src/app/(dashboard)/admin/security/page.tsxsrc/lib/auth/guards/route.ts
- 2
Read security and permission state
Dashboard cards and permission matrix exports are assembled from compliance-owned server queries.
Relevant Product code
src/features/compliance/server/security/queries.tssrc/features/compliance/server/permissions/matrix-query.ts
- 3
Redact audit fields by role
Audit descriptions, values, and redaction helpers keep logs useful without exposing raw sensitive payloads.
Relevant Product code
src/features/compliance/server/audit/query.tssrc/features/compliance/server/audit/redaction.tssrc/features/compliance/server/audit/values.ts
- 4
Run retention as protected work
Retention cleanup is handled by the compliance service behind the protected cron route.
Relevant Product code
src/features/compliance/server/retention/service.ts
Audit redaction branch
Use this example as a starting point, then adapt it to your product's rules and configuration.
Profile audit entries preserve role changes but remove raw metadata and sensitive state.
if (entry.entityType === "profile") {
return {
...entry,
actorEmail: maskedActorEmail,
targetLabel: maskedTargetLabel,
description: maskedDescription,
metadata: {},
beforeState: pickObjectKeys(entry.beforeState, ["role"]),
afterState: pickObjectKeys(entry.afterState, ["role"]),
redacted: true,
};
}Source reference
src/features/compliance/server/audit/redaction.ts
Compliance rules
- Keep admin-only pages behind server-side role checks.
- Do not log secrets, raw tokens, or full provider payloads.
- Preserve stable identifiers in audit entries.
- Treat retention work as operational work and make it easy to verify.