Background/Goal
When executed locally, the new AQS 2.0 services are currently not sending the same response headers as the existing production service are when executed from our production infrastructure. Notably, there are differences in security- and caching-related headers, as well as some others.
Determine which of these headers will be the responsibility of the service and which will be the responsibility of another layer (Load Balancer, Varnish, etc. I don't think the prod endpoints are going through the API Gateway at this time). Revise as needed to make the new service header output match production.
If we can make this easier (both for ourselves now and also for any future services) by pushing some of the service changes to the scaffold/servicelib level, we should do that as part of this task. Keep in mind that even if all services need to send the same set of headers, different services may need to send different values for them. So consider making scaffold/servicelib changes configurable.
Unit tests should be created for any service changes. Once the scope of service-level changes is complete, we should consider whether a separate QA ticket is needed for related integration testing.
I compared the following requests:
- https://wikimedia.org/api/rest_v1/metrics/unique-devices/en.wikipedia/all-sites/daily/20210101/20210201
- http://localhost:8080/metrics/unique-devices/en.wikipedia/all-sites/daily/20210101/20210201
Here are the related headers that I see the existing production service sending, as compared to the new AQS 2.0 services (I checked via Device Analytics, presumably the other services are the same):
| header | production value |
| accept-ch | Sec-CH-UA-Arch,Sec-CH-UA-Bitness,Sec-CH-UA-Full-Version-List,Sec-CH-UA-Model,Sec-CH-UA-Platform-Version |
| accept-ranges | bytes |
| access-control-allow-headers | accept, content-type, content-length, cache-control, accept-language, api-user-agent, if-match, if-modified-since, if-none-match, dnt, accept-encoding |
| access-control-allow-methods | GET,HEAD |
| access-control-allow-origin | * |
| access-control-expose-headers | etag |
| cache-control | s-maxage=14400, max-age=14400 |
| content-security-policy | default-src 'none'; frame-ancestors 'none' |
| nel (Network Error Logging) | { "report_to": "wm_nel", "max_age": 86400, "failure_fraction": 0.05, "success_fraction": 0.0} |
| permissions-policy | interest-cohort=(),ch-ua-arch=(self "intake-analytics.wikimedia.org"),ch-ua-bitness=(self "intake-analytics.wikimedia.org"),ch-ua-full-version-list=(self "intake-analytics.wikimedia.org"),ch-ua-model=(self "intake-analytics.wikimedia.org"),ch-ua-platform-version=(self "intake-analytics.wikimedia.org") |
| referrer-policy | origin-when-cross-origin |
| report-to | { "group": "wm_nel", "max_age": 86400, "endpoints": [{ "url": "https://intake-logging.wikimedia.org/v1/events?stream=w3c.reportingapi.network_error&schema_uri=/w3c/reportingapi/network_error/1.0.0" }] } |
| strict-transport-security | max-age=106384710; includeSubDomains; preload |
| vary | Accept-Encoding |
| x-content-security-policy | default-src 'none'; frame-ancestors 'none' |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-webkit-csp | default-src 'none'; frame-ancestors 'none' |
| x-xss-protection | 1; mode=block |
The only headers in this list currently provided by the AQS 2.0 services are x-frame-options (which uses the value "deny" instead of the production value) and x-xss-protection (which uses a similar but not identical value as production).
The only headers in this list that I found in the production AQS codebase was cache-control. It is possible I missed something. But if not, that suggests another layer is providing them. If I'm right about that, then there may be very little to do for this task. But we should be sure.
Acceptance Criteria
- 1. the common function is implemented
- 2. tasks for individual services are created
Tasks to be performed as part of acceptance criteria
This is just a list of the same headers as the above table, but in checkbox form, so that they can be marked off as we verify for each that either another layer provides them (and we therefore have no changes to make) or any necessary changes are made.
- accept-ch
- accept-ranges
- access-control-allow-headers
- access-control-allow-methods
- access-control-allow-origin
- access-control-expose-headers
- cache-control
- content-security-policy
- nel
- permissions-policy
- referrer-policy
- report-to
- strict-transport-security
- vary
- x-content-type-options
- x-frame-options
- x-xss-protection
And don't forget:
- integration testing implications are considered and any necessary QA task is created
Artifacts & Resources
As a reminder, what we were previously calling "Unique Devices" is now called "Device Analytics" and its code is in gerrit, not gitlab:
The other services remain in gitlab. However, the service scaffolding and servicelib repositories are in gerrit.