Page MenuHomePhabricator

Implement a compatibility layer between RESTBase and native PCS responses
Closed, ResolvedPublic

Description

Background Information

Other than providing a storage layer, RESTBase implements some logic for the services that it proxies the requests.
Specifically:

  • lib/access_check_filter.js
    • Checks if a page is restriced and returns a redirect instead
  • lib/security_response_header_filter.js
    • Adds security related headers to responses
      • CSP
      • CORS
      • x-content-type-options, x-frame-options
      • referrer-policy
      • x-xss-protection
  • lib/language_variants_filter.js
    • Checks MW API for language variants for each request and adds language headers
  • lib/ensure_content_type.js
    • Enforces the response content type
      1. compares the returned content-type with the first entry of the produces array in the route spec, and
      2. repeats the request with no-cache header set if:
        • the profile parameter does not match, and
        • either the path (without version) differs, or the expected version is higher than the returned version, and
        • the page has not been re-rendered within the last two minutes.

What

We need to make sure that all of them are still needed and provide compatibility on mobileapps level when serving requests without RESTBase

Acceptance Criteria

  • PCS applies lib/access_check_filter.js logic without RESTBase T321195
  • PCS applies lib/security_response_header_filter.js logic without RESTBase T321194
  • PCS applies lib/ensure_content_type.js logic without RESTBase T321199
  • PCS applies lib/language_variants_filter.js logic without RESTBase T317019
    • Ensure PCS does not need a compatibility layer
  • lib/language_variants_filter.js
    • Checks MW API for language variants for each request and adds language headers

The v1/page/{title} endpoint will soon have support for this, see T317019

Event Timeline

Can we create automated smoke tests to perform these checks before implementing the compatibility layer? That might be useful for future services as well.

  • lib/access_check_filter.js
    • Checks if a page is restriced and returns a redirect instead

MW core endpoints always perform access checks.

  • lib/security_response_header_filter.js
  • Adds security related headers to responses
    • CSP
    • CORS
    • x-content-type-options, x-frame-options
    • referrer-policy
    • x-xss-protection

MW core handles some of these, but it's unclear whether it does so comprehensively and consistency. E.g.

  • The ContentSercurityPolicy handles CSP and CORS, and is used by OutputPage
  • ResourceLoader's ClientHtml seems to have it's own CSP handling
  • There is a ReferrerPolicy setting, but it doesn't seem to be used to set HTTP headers
  • lib/language_variants_filter.js
    • Checks MW API for language variants for each request and adds language headers

The v1/page/{title} endpoint will soon have support for this, see T317019

  • lib/ensure_content_type.js
    • Enforces the response content type

It's not clear whether this is needed at all. If it is, it should probably be implemented in the v1/page/{title} endpoint .

daniel triaged this task as Medium priority.Nov 22 2022, 6:40 PM

@BPirkle have a peek at this. Any red flags here for successfully deploying T263489: AQS 2.0?

@daniel what are your thoughts here? is this something you can drive as owner?

@daniel what are your thoughts here? is this something you can drive as owner?

This is really just a tracking ticket, the meat is in thje subtasks. @Jgiannelos and @MSantos are working on them.

MSantos claimed this task.

The last task is considered a nice-to-have and also not part of PCS layer. The conversations can continue in that task and I'll be bold and close this one for now, please re-open in case I'm missing something.