Skip to content

Add event type information for audit events using AuditEventService in `User`

Problem to solve

Some audit events are named audit_operation. This isn't a descriptive name and makes it difficult to differentiated from other events.

Additional context is available in this epic and in the parent epic.

Proposal

Add a meaningful name for the following events and actions that can be used to differentiate them from other events:

Event Action Location
email Create file
Create user Create file
Destroy user Delete file
User impersonation at instance level unknown file
Ask for password reset unknown file
omniauth failed login unknown file
Instance access request unknown file
Instance access request approved unknown file
Instance access request rejected unknown file
block user unknown file
OAuth application added unknown file
Add user to group saml unknown file
Added SSH key unknown file

Naming should follow the noun_verb format and use the past tense. For example ci_variable_created.

For events created with audit_changes we can pass the event name using the event_type argument.

audit_changes(:email, as: 'email address', event_type: 'email_address_added')

Consider this MR as an example of how to do this.

Implementation plan

  1. Add an meaningful event name for the events in the User model listed in the proposal.
    • The name should follow the noun_verb format.
  2. Update the associated specs.

Validation Steps

User services

These services can be triggered through actions in Admin > Overview > Users:

  1. Create a user using the "New User" button.
  2. Delete a user (this may take a while to process).
  3. Block a user.

The above should each generate an audit event. To trigger approve/reject events, register a new user in the login page, then accept or reject that user through the admin role.

Passwords controller

This is an instance-level audit event and must be verified with admin access. This may only be possible in a local environment.

  1. Log out
  2. Click the password reset link
  3. Open the generated reset email and click the link
  4. Choose a new password
  5. Verify an audit event is created: Screenshot_2023-03-31_at_3.40.41_AM

Omniauth failed login

  1. Log out
  2. Attempt to login via google. This should fail by default in a local GDK environment.
  3. Verify the audit event.

Registrations Controller

  1. Log out
  2. Click register to request a new account.
  3. Log in as admin
  4. Verify the audit event.

Notes

Edited by Aaron Huntsman