Skip to content
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

Audit: track downloads separately from page views #8619

Merged
merged 2 commits into from
Oct 27, 2021
Merged

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Oct 26, 2021

No description provided.

@stsewd stsewd requested a review from a team as a code owner October 26, 2021 20:57
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks simple enough, but think we probably want to capture a bit more data here 👍

AuditLog.objects.new(
action=AuditLog.PAGEVIEW,
action=action,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be capturing the path or similar here? Seems like "downloaded a thing" isn't as useful as "downloaded this file".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's already extracted from the request

if request:
kwargs['ip'] = get_client_ip(request)
kwargs['browser'] = request.headers.get('User-Agent')
kwargs.setdefault('resource', request.path_info)
kwargs.setdefault('auth_backend', get_auth_backend(request))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, awesome :)

@stsewd stsewd merged commit dbe27b3 into master Oct 27, 2021
@stsewd stsewd deleted the track-downloads-audit branch October 27, 2021 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants