@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Fix an issue where Duo validation could incorrectly apply to other factor types

See <https://discourse.phabricator-community.org/t/configuring-mfa-provider-totp-fails-for-missing-duo-only-options/2355>.

Test Plan: Created a TOTP provider; created a Duo provider (with missing and supplied values).

+17 -1
+4
src/applications/auth/xaction/PhabricatorAuthFactorProviderDuoCredentialTransaction.php
··· 27 27 $actor = $this->getActor(); 28 28 $errors = array(); 29 29 30 + if (!$this->isDuoProvider($object)) { 31 + return $errors; 32 + } 33 + 30 34 $old_value = $this->generateOldValue($object); 31 35 if ($this->isEmptyTextTransaction($old_value, $xactions)) { 32 36 $errors[] = $this->newRequiredError(
+4
src/applications/auth/xaction/PhabricatorAuthFactorProviderDuoHostnameTransaction.php
··· 26 26 public function validateTransactions($object, array $xactions) { 27 27 $errors = array(); 28 28 29 + if (!$this->isDuoProvider($object)) { 30 + return $errors; 31 + } 32 + 29 33 $old_value = $this->generateOldValue($object); 30 34 if ($this->isEmptyTextTransaction($old_value, $xactions)) { 31 35 $errors[] = $this->newRequiredError(
+9 -1
src/applications/auth/xaction/PhabricatorAuthFactorProviderTransactionType.php
··· 1 1 <?php 2 2 3 3 abstract class PhabricatorAuthFactorProviderTransactionType 4 - extends PhabricatorModularTransactionType {} 4 + extends PhabricatorModularTransactionType { 5 + 6 + final protected function isDuoProvider( 7 + PhabricatorAuthFactorProvider $provider) { 8 + $duo_key = id(new PhabricatorDuoAuthFactor())->getFactorKey(); 9 + return ($provider->getProviderFactorKey() === $duo_key); 10 + } 11 + 12 + }