Skip to main content

Audit Events

Rampart records a comprehensive audit trail of all security-relevant actions. Every authentication attempt, role change, session operation, and administrative action is captured as an immutable event. The audit log is essential for security monitoring, incident response, compliance reporting, and operational debugging.

Event Types

Rampart defines a structured set of event types organized by category. Each event type uses a category.action naming convention.

Authentication Events

Event TypeDescriptionSeverity
auth.loginUser successfully authenticatedinfo
auth.login_failedAuthentication attempt failed (wrong password, unknown user, locked account)warning
auth.logoutUser logged outinfo
auth.mfa_challengeMFA challenge issued after primary authenticationinfo
auth.mfa_successMFA verification succeededinfo
auth.mfa_failedMFA verification failedwarning
auth.password_reset_requestedPassword reset email was sentinfo
auth.password_reset_completedPassword was reset via reset linkinfo
auth.password_changedUser changed their password (while authenticated)info
auth.account_lockedAccount locked due to repeated failed attemptswarning
auth.account_unlockedAccount unlocked by admin or automatic timeoutinfo

Token Events

Event TypeDescriptionSeverity
token.issuedAccess/refresh tokens issuedinfo
token.refreshedTokens refreshed via refresh tokeninfo
token.revokedToken explicitly revokedinfo
token.replay_detectedA previously used refresh token was presented (potential theft)critical
token.introspectedToken introspection endpoint calledinfo

Session Events

Event TypeDescriptionSeverity
session.createdNew session establishedinfo
session.revokedSingle session revokedinfo
session.bulk_revokedMultiple sessions revoked in one operationwarning
session.expiredSession expired due to timeoutinfo
session.suspiciousSuspicious session activity detected (IP change, user agent change)warning
session.impossible_travelGeo-location inconsistency detectedcritical

User Management Events

Event TypeDescriptionSeverity
user.createdNew user registered or created by admininfo
user.updatedUser profile updatedinfo
user.deletedUser account deletedwarning
user.disabledUser account disabledwarning
user.enabledUser account re-enabledinfo
user.migratedUser moved to a different organizationwarning
user.mfa_enrolledUser enrolled in MFAinfo
user.mfa_disabledUser or admin disabled MFAwarning

Role Events

Event TypeDescriptionSeverity
role.createdCustom role createdinfo
role.updatedRole permissions modifiedwarning
role.deletedCustom role deletedwarning
role.assignedRole assigned to a userinfo
role.unassignedRole removed from a userwarning

Client Events

Event TypeDescriptionSeverity
client.createdOAuth client registeredinfo
client.updatedClient configuration modifiedinfo
client.deletedOAuth client deletedwarning
client.secret_rotatedClient secret was rotatedinfo

Organization Events

Event TypeDescriptionSeverity
org.createdNew organization createdinfo
org.updatedOrganization settings modifiedinfo
org.disabledOrganization disabledcritical
org.enabledOrganization re-enabledinfo
org.deletedOrganization permanently deletedcritical

Identity Provider Events

Event TypeDescriptionSeverity
idp.createdIdentity provider configuredinfo
idp.updatedIdentity provider settings modifiedinfo
idp.deletedIdentity provider removedwarning
idp.loginUser authenticated via external identity providerinfo
idp.linkExternal identity linked to existing accountinfo

System Events

Event TypeDescriptionSeverity
system.config_changedInstance-level configuration modifiedwarning
system.key_rotatedSigning key rotatedinfo
system.startupRampart instance startedinfo
system.shutdownRampart instance shut down gracefullyinfo

Event Schema

Every audit event follows a consistent JSON schema. Events are immutable once written — they cannot be modified or deleted through the API.

Schema Definition

{
"event_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"event_type": "auth.login",
"severity": "info",
"timestamp": "2026-03-05T14:22:31.847Z",
"org_id": "acme-corp",
"actor": {
"type": "user",
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "jane@acme.com",
"ip_address": "203.0.113.42",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...",
"geo": "San Francisco, US"
},
"target": {
"type": "session",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
},
"details": {
"method": "password",
"mfa_used": true,
"client_id": "web-app"
},
"request_id": "req-abc123"
}

Field Reference

FieldTypeRequiredDescription
event_idUUIDyesUnique identifier for the event
event_typestringyesThe event type (e.g., auth.login)
severityenumyesinfo, warning, or critical
timestampISO 8601yesWhen the event occurred (UTC, millisecond precision)
org_idstringyesThe organization context (or system for global events)
actorobjectyesWho performed the action
actor.typeenumyesuser, admin, client, or system
actor.idstringyesActor's unique identifier
actor.emailstringnoActor's email (when applicable)
actor.ip_addressstringnoClient IP address
actor.user_agentstringnoClient User-Agent header
actor.geostringnoApproximate location from IP
targetobjectnoThe resource affected by the action
target.typeenumnouser, role, client, session, org, idp
target.idstringnoTarget's unique identifier
detailsobjectnoEvent-specific metadata (varies by event type)
request_idstringnoCorrelation ID for request tracing

Actor Types

Actor TypeDescription
userAn authenticated end user performing a self-service action
adminAn admin user performing an administrative action
clientAn OAuth client acting autonomously (e.g., client credentials flow)
systemThe Rampart system itself (e.g., automatic session expiration, scheduled tasks)

Security Notes on Event Data

  • Sensitive data is never logged. Passwords, tokens, client secrets, and MFA codes are excluded from events.
  • IP addresses are logged. This is necessary for security monitoring but may have privacy implications. See Retention and Compliance for data handling.
  • Events are append-only. There is no API to modify or delete individual events. Retention policies handle cleanup.

Querying Events

Via the Admin API

List events for the current organization:

curl "https://auth.example.com/api/admin/audit-events" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Filter by event type:

curl "https://auth.example.com/api/admin/audit-events?type=auth.login_failed" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Filter by date range:

curl "https://auth.example.com/api/admin/audit-events?since=2026-03-01T00:00:00Z&until=2026-03-05T23:59:59Z" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Filter by actor:

curl "https://auth.example.com/api/admin/audit-events?actor_id=550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Filter by severity:

curl "https://auth.example.com/api/admin/audit-events?severity=critical" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Filter by IP address:

curl "https://auth.example.com/api/admin/audit-events?ip=203.0.113.42" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Combined filters with pagination:

curl "https://auth.example.com/api/admin/audit-events?type=auth.login_failed&severity=warning&since=2026-03-01&limit=50&offset=0" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Response format:

{
"events": [
{
"event_id": "...",
"event_type": "auth.login_failed",
"severity": "warning",
"timestamp": "2026-03-05T14:22:31.847Z",
"actor": { "type": "user", "ip_address": "203.0.113.42", "email": "jane@acme.com" },
"details": { "reason": "invalid_password" }
}
],
"total": 142,
"limit": 50,
"offset": 0
}

Cross-organization query (super_admin only):

curl "https://auth.example.com/api/admin/audit-events?scope=global&type=org.disabled" \
-H "Authorization: Bearer $SUPER_ADMIN_TOKEN"

Via the Admin Console

The admin console provides a visual audit log browser with:

  • Real-time event stream — new events appear automatically at the top of the list
  • Full-text search — search across event types, actor emails, IP addresses, and details
  • Faceted filtering — filter by event category, severity, date range, and actor
  • Event detail view — click any event to see the full JSON payload
  • Export — download filtered events as CSV or JSON for external analysis
  • Visual timeline — timeline view showing event density and patterns over time

Via the CLI

# List recent events
rampart-cli audit list --limit 20

# Filter by type
rampart-cli audit list --type auth.login_failed --since 2026-03-01

# Follow events in real-time
rampart-cli audit tail --severity warning,critical

# Export events
rampart-cli audit export --since 2026-03-01 --format json > events.json

Security Monitoring Patterns

Detect Brute-Force Attacks

Look for repeated auth.login_failed events from the same IP:

curl "https://auth.example.com/api/admin/audit-events?type=auth.login_failed&ip=203.0.113.42&limit=100" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Detect Account Takeover

Look for auth.password_changed events followed by session revocations from a new IP:

curl "https://auth.example.com/api/admin/audit-events?type=auth.password_changed&actor_id={user_id}" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Detect Unauthorized Privilege Escalation

Monitor for role.assigned events where admin roles are being granted:

curl "https://auth.example.com/api/admin/audit-events?type=role.assigned&since=2026-03-01" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Detect Token Theft

Monitor for token.replay_detected events, which indicate a refresh token was used after it had already been consumed:

curl "https://auth.example.com/api/admin/audit-events?type=token.replay_detected&severity=critical" \
-H "Authorization: Bearer $ADMIN_TOKEN"

Retention and Compliance

Retention Policies

Audit events are stored in PostgreSQL. Retention is configurable per organization, with a global default.

SettingDefaultDescription
retention_days90Number of days to retain events before automatic deletion
retention_min_days30Minimum retention period (cannot be set lower)
retention_max_days3650 (10 years)Maximum retention period

Configuration:

audit:
retention:
default_days: 90
min_days: 30
cleanup_schedule: "0 2 * * *" # Run cleanup daily at 2 AM UTC
batch_size: 10000 # Delete in batches to avoid long locks

Per-organization override:

curl -X PUT https://auth.example.com/api/admin/organizations/acme-corp \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"audit_policy": {
"retention_days": 365
}
}'

Cleanup Process

Rampart runs a background job on the configured schedule that:

  1. Identifies events older than the retention period for each organization
  2. Deletes events in configurable batches to avoid locking the database
  3. Logs the cleanup results as a system.audit_cleanup event
  4. Vacuums the events table to reclaim disk space

Compliance Support

Rampart's audit system is designed to support common compliance frameworks:

SOC 2

  • CC6.1 / CC6.2 — All logical access events (login, logout, failed auth) are logged
  • CC6.3 — Role changes and permission modifications are tracked with actor attribution
  • CC7.2 — Security events are monitored and can trigger alerts via webhooks

GDPR

  • Article 30 — Audit logs provide records of processing activities
  • Article 5(1)(f) — Events demonstrate security measures in place
  • Data minimization — events do not contain passwords, tokens, or unnecessary personal data
  • Right to erasure — user-identifying fields in audit events can be pseudonymized via the admin API when a user exercises their right to be forgotten (the event structure is preserved)

HIPAA

  • 164.312(b) — Audit controls record activity in systems containing ePHI
  • 164.312(c)(1) — Immutable audit events ensure integrity of the log
  • 164.308(a)(5)(ii)(C) — Login monitoring provides the basis for security awareness

External Log Shipping

For organizations that use centralized logging systems, Rampart supports shipping audit events to external destinations:

DestinationMethodConfiguration
WebhookHTTP POST for each event or batchedURL, headers, retry policy
SyslogRFC 5424 over TCP/TLSHost, port, facility, TLS config
Stdout/StderrStructured JSON logsLog level filter

Webhook configuration example:

audit:
webhooks:
- url: "https://siem.example.com/api/events"
headers:
Authorization: "Bearer ${SIEM_TOKEN}"
filter:
severity: ["warning", "critical"]
retry:
max_attempts: 3
backoff: "exponential"
batch:
size: 100
interval: "10s"

Events are delivered at least once. Duplicate detection should be handled by the receiver using the event_id field.

Immutability

Audit events are immutable by design:

  • There is no API endpoint to update or delete individual events
  • Retention-based cleanup is the only deletion mechanism
  • Database-level protections (triggers or row-level policies) prevent direct modification
  • Any attempt to tamper with the audit table is itself logged as a system.audit_tamper_detected event

This immutability provides confidence that the audit trail accurately reflects what happened, which is essential for incident investigation and compliance audits.