Skip to content

Record impersonator information on audit event

Tan Le requested to merge tancnle/impersonated-audit-events into master

What does this MR do?

Add impersonator information on audit event. This extra information only available on GitLab Premium.

Relates to #536 (closed)

Design notes

This MR extends the existing current_user in ApplicationController to include impersonator attribute. This user is flows through to AuditEventService via existing interface and later extrapolated within AuditEventService to generate extra impersonator information in audit_events table.

graph LR
   A[Login] --> B{impersonator_id?}
   B --> |No| D[User]
   B --> |Yes| E[User<br/>with Impersonator]
   D & E --> F[AuditEventService]
   F[AuditEventService] --> G{impersonated?}
   G --> |No| H[Author]
   G --> |Yes| I[ImpersonatedAuthor]
   H & I --> J[Audit Event]

We've also discussed in great length about the Author concept in Audit land, whether the author is the impersonator or the user being impersonated. At the end, we decided to go with the later to align with the current_user thinking in the controller.

Screenshots

Screen_Shot_2020-05-08_at_12.00.22_pm

Screen_Shot_2020-05-08_at_12.05.53_pm

JSON Audit Logs
{
  "severity": "INFO",
  "time": "2020-05-08T01:54:40.338Z",
  "correlation_id": "OW7IPT5Mt6",
  "author_id": 28,
  "entity_id": 12,
  "entity_type": "Project",
  "change": "prevent merge request approval from reviewers",
  "from": "false",
  "to": "true",
  "author_name": "Bruce Wayne",
  "target_id": 12,
  "target_type": "Project",
  "target_details": "gitlab-org/gitlab-ops",
  "ip_address": "127.0.0.1",
  "entity_path": "gitlab-org/gitlab-ops",
  "impersonated_by": "Harry Potter"
}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Tan Le

Merge request reports