Page MenuHomePhabricator

Refactor UserRequirementsConditionChecker so that 2FA assumption in OATHAuth can be done without extending full checker
Closed, ResolvedPublic

Description

The UserRequirementsConditionChecker does two things currently. It parses the condition, which may be compound, and evaluates a set of core conditions.

OATHAuth defines also its own condition checker, which can make assumptions about 2FA status, so that it can be determined, whether user is obliged to have 2FA enabled. In practice it only needs to override how the atomic conditions are evaluated, but for that it has to extend the full class, which includes a lot of unrelated logic.

In this setting, adding new conditions to core (and thus, adding new dependencies in constructor) will require updating the OATHAuth's ServiceWiring. It's very easy to oversee this and block some CIs or start triggering logspam on prod.

Idea

The UserRequirementsConditionChecker is split into two classes – one responsible for going through compound conditions, and managing the general syntax of them. The second class will support the atomic conditions already defined in core.

In such scenario, the top-level condition checker will be created with an array of atomic condition checkers, so that adding new conditions won't require fundamental and possibly breaking changes to the whole object. OATHAuth will be then able to create the condition checker with a custom set of evaluators.

Event Timeline

Change #1264566 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/core@master] Extract condition evaluation from UserRequirementsConditionChecker

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

Change #1264568 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/OATHAuth@master] Check mandatory 2FA without extending UserRequirementsConditionChecker

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

Change #1264567 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/core@master] Drop unneeded fields from UserRequirementsConditionChecker

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

Change #1264566 merged by jenkins-bot:

[mediawiki/core@master] Extract condition evaluation from UserRequirementsConditionChecker

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

Change #1264568 merged by jenkins-bot:

[mediawiki/extensions/OATHAuth@master] Check mandatory 2FA without extending UserRequirementsConditionChecker

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

Change #1264567 merged by jenkins-bot:

[mediawiki/core@master] Drop unneeded fields from UserRequirementsConditionChecker

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

Change #1268848 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/core@master] Add @since to method in UserRequirementsConditionCheckerFactory

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

Change #1268848 merged by jenkins-bot:

[mediawiki/core@master] Add @since to method in UserRequirementsConditionCheckerFactory

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