-
Notifications
You must be signed in to change notification settings - Fork 69
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
Log HTTP referer and origin #1429
Conversation
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.
Please also add to the log_info_with_request()
method!
src/server/_common.py
Outdated
req_referrer=request.referrer, | ||
req_origin=request.environ.get('HTTP_ORIGIN', '') |
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.
-
Can you move this to right underneath
user_agent=...
(since they come from the same place (request headers) and because they both identify client context)? -
Why not just use
request.origin
? Presumably so you can default to the empty string, but why prefer that overNone
? -
We dont need to keep both values; if both are provided, refer[r]er should be a superstring of origin.
req_referrer=request.referrer, | |
req_origin=request.environ.get('HTTP_ORIGIN', '') | |
refer_origin=request.referrer or request.origin, |
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.
Fixed!
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.
just a couple quick changes and we should be good :)
Quality Gate passedIssues Measures |
Related: #1386.
Summary:
Logs the HTTP Referer (or referrer) header as
req_referrer
and Origin header asreq_origin
, helping us track where requests come from. The easiest way to test this is via Postman:This generates the following log string:
An automated version of this test has also been included. If no referrer is present, the HTTP
Origin
is used instead.As mentioned in #1386, we might also need to modify the referrer policy across our webapps in order to properly set the relevant fields. The default referrer policy is:
Since the API endpoint is HTTPS, for some webapps these headers are likely to be already set out of the box, but further testing will still be necessary.
Prerequisites:
dev
branchdev