-
Notifications
You must be signed in to change notification settings - Fork 479
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
implement Request#gdpr? #22526
implement Request#gdpr? #22526
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
require 'rack/request' | ||
require 'ipaddr' | ||
require 'json' | ||
require 'country_codes' | ||
|
||
module Cdo | ||
module RequestExtension | ||
|
@@ -101,6 +102,15 @@ def user_id_from_session_cookie | |
rescue | ||
return nil | ||
end | ||
|
||
def country | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just confirming: do both the cloudfront country and the fallback country work for Pegasus requests too? And country is now part of the cache variant for all sites? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, this won't work for [all] Pegasus requests as it's currently configured, because country isn't added to the cache variant for cached pages. I've only added the country header to non-cached CloudFront path behaviors for now to avoid impact on any existing cache behavior. If we do end up with cases where we want to vary cached page-responses based on country-code (in addition to the language-varying we already do on these pages), we can change the cache configuration to make that work as well. However, such a change would multiply the number of uniquely-cached pages by the number of countries (so the total variants for each cached page will be languages * countries * user_types). This would probably be fine, but would be significant enough cache change that we'd want to watch for any increased load when deploying. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a followup, we now do vary the pegasus caching by country courtesy of #26753. |
||
env['HTTP_CLOUDFRONT_VIEWER_COUNTRY'] || | ||
location&.country_code | ||
end | ||
|
||
def gdpr? | ||
gdpr_country_code?(country) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently we've been using EEA as a broader catch-all, rather than EU. Maybe we could have the option to query either? @poorvasingal can comment fully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just been trying to use EEA to be more broad / play it safer. EEA = EU + Iceland, Liechtenstein and Norway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
end | ||
end | ||
end | ||
Rack::Request.prepend Cdo::RequestExtension | ||
|
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.
We've been trying to avoid this phrase. "Accept list" or something else instead?
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.
I'm leaving this for now for consistency with the rest of the existing file and with the CloudFront API terminology, but will follow up on whether we have a need to adopt/clarify naming guidelines moving forward.