Page MenuHomePhabricator

Create rest endpoint for executing jobs instead of /rpc/RunSingleJob
Closed, ResolvedPublic

Description

As discussed in the parent RFC, we want to move the code that executes posted job from a tacky /rpc/RunSingleJob.php script located in mediawiki-config repo to a REST endpoint.

The RFC T175146 suggests a special page as a solution, but it was proposed before MW core had REST capabilities, and really a REST endpoint is what we need.

The endpoint will be protected from arbitrary code execution by signing events with MW secret key and verifying the signature.

Event Timeline

Change 571816 had a related patch set uploaded (by Clarakosi; owner: Clarakosi):
[mediawiki/extensions/EventBus@master] REST endpoint for executing jobs

https://gerrit.wikimedia.org/r/571816

Question: wouldn't it be better if we just had a configuration swtich that either allows or disallows access to this endpoint (set to false by default)?

In general, I'd expect it to be more straighforward to implement and it prevents casual users to leave the door open to job execution from the internet if they happen to leak their configuration.

Question: wouldn't it be better if we just had a configuration swtich that either allows or disallows access to this endpoint (set to false by default)?

Yeah, that's the plan. See T244770 where I'm even wondering whether it's possible to only turn it on on the JobRunner cluster of MW.

Summary from T175146#5882126:

As of Feb 2020, the following are at play:

  • MediaWiki core: Special:RunJobs (default for MW)
    • Protected at run-time by HMAC/SHA1
  • MediaWiki-EventBus extension: Special:RunSingleJob (unused?)
    • Protected at run-time by JWT/sha256
  • WMF: rpc/RunJobs.php (unused?)
    • Protected at run-time by REMOTE_ADDR check (localhost-only).
    • Protected structurally as it is only exposed on a non-public pool of app servers.
  • WMF: rpc/RunSingleJob.php
    • Not protected at run-time.
    • Protected structurally as it is only exposed on a non-public pool of app servers.

Change 575316 had a related patch set uploaded (by Clarakosi; owner: Clarakosi):
[integration/config@master] Enable api-testing in EventBus

https://gerrit.wikimedia.org/r/575316

Change 575316 merged by jenkins-bot:
[integration/config@master] Enable api-testing in EventBus

https://gerrit.wikimedia.org/r/575316

Change 571816 merged by jenkins-bot:
[mediawiki/extensions/EventBus@master] REST endpoint for executing jobs

https://gerrit.wikimedia.org/r/571816

Change 575334 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[mediawiki/extensions/EventBus@master] REST Api-Testing: Fix job definition to awoid PHP warnings.

https://gerrit.wikimedia.org/r/575334

Change 575334 merged by jenkins-bot:
[mediawiki/extensions/EventBus@master] REST Api-Testing: Fix job definition to avoid PHP warnings

https://gerrit.wikimedia.org/r/575334