-
Notifications
You must be signed in to change notification settings - Fork 4
add audit events for GET endpoints #678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
api/versions.go
Outdated
| return nil, errs.ErrResourceState | ||
| } | ||
|
|
||
| if authorised && isStatic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no requirement to check for static types as part of this work.
| } | ||
|
|
||
| // ID and Email are the same as auth middleware can only provide userID | ||
| if err := api.auditService.RecordVersionAuditEvent(ctx, models.RequestedBy{ID: authEntityData.UserID, Email: authEntityData.UserID}, models.ActionRead, "/datasets/"+datasetID+"/editions/"+editionID, versionToAudit); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to just before the response is returned to the user to ensure all the fields are completed (e.g. those completed via URL re-writing) and the edition model recorded if it is not a static dataset.
| } | ||
|
|
||
| // ID and Email are the same as auth middleware can only provide userID | ||
| if err := api.auditService.RecordVersionAuditEvent(ctx, models.RequestedBy{ID: authEntityData.UserID, Email: authEntityData.UserID}, models.ActionRead, "/datasets/"+datasetID+"/editions/"+edition+"/versions/"+version+"/metadata", versionDoc); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metadata object should be recorded here instead of versionDoc
What
Implement event tracking on GET endpoints
Jira - https://officefornationalstatistics.atlassian.net/browse/DIS-4411
How to review
To test locally, make a GET request to the endpoints specified in the acceptance criteria, and confirm that events are logged in the
dataset_eventsdatabase in mongodbChanges make sense, tests pass
Who can review
Anyone