Pure functions for creating audit log entries.
This namespace contains CORE (pure) functions for audit trail management. In FC/IS architecture, this is the CORE that:
Key FC/IS principles:
Pure functions for creating audit log entries. This namespace contains CORE (pure) functions for audit trail management. In FC/IS architecture, this is the CORE that: - Contains pure business logic for audit entry creation - No side effects - returns data structures only - All I/O is delegated to shell layer (persistence) Key FC/IS principles: - Pure functions only - deterministic, no side effects - Returns data that shell layer will persist - Business rules for what gets audited and how
(activate-user-audit-entry actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)Create audit log entry for user activation.
Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being activated target-user-email: Email of user being activated ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map
Create audit log entry for user activation. Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being activated target-user-email: Email of user being activated ip-address: Optional IP address user-agent: Optional user agent string Returns: Audit log entity map
(bulk-action-audit-entry actor-id
actor-email
action-type
user-ids
ip-address
user-agent
additional-metadata)Create audit log entry for bulk operations.
Args: actor-id: UUID of user who performed the action actor-email: Email of actor action-type: Type of bulk action (:deactivate, :activate, :delete, :role-change) user-ids: Vector of affected user IDs ip-address: Optional IP address user-agent: Optional user agent string additional-metadata: Optional map with extra context
Returns: Audit log entity map
Note: For bulk operations, we create one audit entry per affected user, each with metadata indicating it was part of a bulk operation.
Create audit log entry for bulk operations.
Args:
actor-id: UUID of user who performed the action
actor-email: Email of actor
action-type: Type of bulk action (:deactivate, :activate, :delete, :role-change)
user-ids: Vector of affected user IDs
ip-address: Optional IP address
user-agent: Optional user agent string
additional-metadata: Optional map with extra context
Returns:
Audit log entity map
Note: For bulk operations, we create one audit entry per affected user,
each with metadata indicating it was part of a bulk operation.(create-user-audit-entry actor-id actor-email target-user ip-address user-agent)Create audit log entry for user creation.
Pure function that constructs audit log data structure.
Args: actor-id: UUID of user who performed the action (nil for system) actor-email: Email of actor target-user: Created user entity map ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map ready for persistence
Example: (create-user-audit-entry admin-id "admin@example.com" new-user "192.168.1.1" "Mozilla...")
Create audit log entry for user creation. Pure function that constructs audit log data structure. Args: actor-id: UUID of user who performed the action (nil for system) actor-email: Email of actor target-user: Created user entity map ip-address: Optional IP address user-agent: Optional user agent string Returns: Audit log entity map ready for persistence Example: (create-user-audit-entry admin-id "admin@example.com" new-user "192.168.1.1" "Mozilla...")
(data-export-audit-entry {:keys [actor-id actor-email ip-address user-agent]}
target)Audit log entry for an admin downloading target's data export: who read
another person's data, and when.
Audit log entry for an admin downloading `target`'s data export: who read another person's data, and when.
(deactivate-user-audit-entry actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)Create audit log entry for user deactivation (soft delete).
Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being deactivated target-user-email: Email of user being deactivated ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map
Create audit log entry for user deactivation (soft delete). Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being deactivated target-user-email: Email of user being deactivated ip-address: Optional IP address user-agent: Optional user agent string Returns: Audit log entity map
(delete-user-audit-entry actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)Create audit log entry for a soft delete: the user is marked deleted and can no longer sign in, the row stays.
Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being deleted target-user-email: Email of user being deleted ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map
Create audit log entry for a soft delete: the user is marked deleted and can no longer sign in, the row stays. Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being deleted target-user-email: Email of user being deleted ip-address: Optional IP address user-agent: Optional user agent string Returns: Audit log entity map
(group-audit-entries action ctx group members grants)(group-audit-entries action
{:keys [actor-id actor-email ip-address user-agent]}
group
members
grants
effective)An entry for each of members whose rights changed: on :group-join or
:group-leave the member who joined or left, gaining or losing the group's
grants; on :grant-add or :grant-remove every member, gaining or losing
the one grant. The log is per user, so a grant changed in an empty group
records nothing: nobody's rights changed. A join lists the grants, so each
user's entries account for what they hold. effective, {user-id-string
diff}, adds what the change did to that member's effective rights
(BOU-852).
An entry for each of `members` whose rights changed: on :group-join or
:group-leave the member who joined or left, gaining or losing the group's
`grants`; on :grant-add or :grant-remove every member, gaining or losing
the one grant. The log is per user, so a grant changed in an empty group
records nothing: nobody's rights changed. A join lists the grants, so each
user's entries account for what they hold. `effective`, {user-id-string
diff}, adds what the change did to that member's effective rights
(BOU-852).(login-audit-entry user-id
user-email
ip-address
user-agent
success?
error-message)Create audit log entry for user login.
Args: user-id: UUID of user who logged in user-email: Email of user ip-address: IP address of login user-agent: User agent string success?: Whether login was successful error-message: Optional error message if login failed
Returns: Audit log entity map
Create audit log entry for user login. Args: user-id: UUID of user who logged in user-email: Email of user ip-address: IP address of login user-agent: User agent string success?: Whether login was successful error-message: Optional error message if login failed Returns: Audit log entity map
(logout-audit-entry user-id user-email ip-address user-agent)Create audit log entry for user logout.
Args: user-id: UUID of user who logged out user-email: Email of user ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map
Create audit log entry for user logout. Args: user-id: UUID of user who logged out user-email: Email of user ip-address: Optional IP address user-agent: Optional user agent string Returns: Audit log entity map
(mfa-disabled-audit-entry user-id user-email ip-address user-agent)Audit log entry for a user turning off their own second factor.
Audit log entry for a user turning off their own second factor.
(mfa-enrolled-audit-entry user-id user-email ip-address user-agent)Audit log entry for a user setting up a second factor at sign-in, with the password alone: after an admin reset, or on registering.
Audit log entry for a user setting up a second factor at sign-in, with the password alone: after an admin reset, or on registering.
(mfa-reset-audit-entry actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)Audit log entry for an admin turning off another user's second factor.
Audit log entry for an admin turning off another user's second factor.
(permanently-delete-user-audit-entry actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)Audit log entry for a permanent delete: the user's rows are gone (BOU-682).
Same arguments as delete-user-audit-entry.
Audit log entry for a permanent delete: the user's rows are gone (BOU-682). Same arguments as `delete-user-audit-entry`.
The actions a change to a user's rights is audited as.
The actions a change to a user's rights is audited as.
(rights-timeline entries n)The newest n of entries, audit entries of rights-actions, newest
first, each {:at :actor :action :group-id :group-name :added :removed},
the rights the change gave and took (BOU-852). A change to Everyone has
:permissions and :affected-count instead; an entry from before BOU-852
none of these.
The newest `n` of `entries`, audit entries of `rights-actions`, newest
first, each {:at :actor :action :group-id :group-name :added :removed},
the rights the change gave and took (BOU-852). A change to Everyone has
:permissions and :affected-count instead; an entry from before BOU-852
none of these.(role-change-audit-entry actor-id
actor-email
target-user-id
target-user-email
old-role
new-role
ip-address
user-agent)Create audit log entry for user role change.
Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user whose role changed target-user-email: Email of user old-role: Previous role keyword new-role: New role keyword ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map
Create audit log entry for user role change. Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user whose role changed target-user-email: Email of user old-role: Previous role keyword new-role: New role keyword ip-address: Optional IP address user-agent: Optional user agent string Returns: Audit log entity map
(sanitize-audit-metadata metadata)Remove sensitive data from audit metadata before persistence.
Pure function that filters out password fields, tokens, etc.
Args: metadata: Metadata map that may contain sensitive data
Returns: Sanitized metadata map
Remove sensitive data from audit metadata before persistence. Pure function that filters out password fields, tokens, etc. Args: metadata: Metadata map that may contain sensitive data Returns: Sanitized metadata map
(session-revoked-audit-entry session-id
actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)Audit log entry for ending one of target-user-id's sessions, by an admin
or by the user themselves (BOU-698).
Audit log entry for ending one of `target-user-id`'s sessions, by an admin or by the user themselves (BOU-698).
(sessions-revoked-audit-entry n
kept-session-id
actor-id
actor-email
target-user-id
target-user-email
ip-address
user-agent)One audit entry for ending n of the user's sessions at once, every one
but kept-session-id when there is one (BOU-708).
One audit entry for ending `n` of the user's sessions at once, every one but `kept-session-id` when there is one (BOU-708).
(update-user-audit-entry actor-id
actor-email
target-user-id
target-user-email
old-values
new-values
ip-address
user-agent)Create audit log entry for user update.
Args: actor-id: UUID of user who performed the action actor-email: Email of actor target-user-id: UUID of user being updated target-user-email: Email of user being updated old-values: Map of old field values new-values: Map of new field values ip-address: Optional IP address user-agent: Optional user agent string
Returns: Audit log entity map
Example: (update-user-audit-entry actor-id "admin@example.com" user-id "user@example.com" {:role :user} {:role :admin} "192.168.1.1" nil)
Create audit log entry for user update.
Args:
actor-id: UUID of user who performed the action
actor-email: Email of actor
target-user-id: UUID of user being updated
target-user-email: Email of user being updated
old-values: Map of old field values
new-values: Map of new field values
ip-address: Optional IP address
user-agent: Optional user agent string
Returns:
Audit log entity map
Example:
(update-user-audit-entry actor-id "admin@example.com" user-id "user@example.com"
{:role :user} {:role :admin} "192.168.1.1" nil)(valid-audit-entry? audit-entry)Validate that an audit entry has all required fields.
Args: audit-entry: Audit entry map to validate
Returns: Boolean indicating if entry is valid
Validate that an audit entry has all required fields. Args: audit-entry: Audit entry map to validate Returns: Boolean indicating if entry is valid
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |