Record impersonator information on audit event
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
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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