Skip to content

Commit 12c3370

Browse files
author
epriestley
committedJan 30, 2020
When issuing a "no-op" MFA token because no MFA is configured, don't give the timeline story a badge
Summary: Fixes T13475. Sometimes, we issue a "no op" / "default permit" / "unchallenged" MFA token, when a user with no MFA configured does something which is configured to attempt (but not strictly require) MFA. An example of this kind of action is changing a username: usernames may be changed even if MFA is not set up. (Some other operations, notably "Sign With MFA", strictly require that MFA actually be set up.) When a user with no MFA configured takes a "try MFA" action, we see that they have no factors configured and issue a token so they can continue. This is correct. However, this token causes the assocaited timeline story to get an MFA badge. This badge is incorrect or at least wildly misleading, since the technical assertion it currently makes ("the user answered any configured MFA challenge to do this, if one exists") isn't explained properly and isn't useful anyway. Instead, only badge the story if the user actually has MFA and actually responded to some kind of MFA challege. The badge now asserts "this user responded to an MFA challenge", which is expected/desired. Test Plan: - As a user with no MFA, renamed a user. Before patch: badged story. After patch: no badge. - As a user with MFA, renamed a user. Got badged stories in both cases. Maniphest Tasks: T13475 Differential Revision: https://secure.phabricator.com/D20958
1 parent c99485e commit 12c3370

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
<?php
22

3-
final class PhabricatorAuthHighSecurityToken extends Phobject {}
3+
final class PhabricatorAuthHighSecurityToken
4+
extends Phobject {
5+
6+
private $isUnchallengedToken = false;
7+
8+
public function setIsUnchallengedToken($is_unchallenged_token) {
9+
$this->isUnchallengedToken = $is_unchallenged_token;
10+
return $this;
11+
}
12+
13+
public function getIsUnchallengedToken() {
14+
return $this->isUnchallengedToken;
15+
}
16+
17+
}

‎src/applications/auth/engine/PhabricatorAuthSessionEngine.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ private function newHighSecurityToken(
493493
// adds an auth factor, existing sessions won't get a free pass into hisec,
494494
// since they never actually got marked as hisec.
495495
if (!$factors) {
496-
return $this->issueHighSecurityToken($session, true);
496+
return $this->issueHighSecurityToken($session, true)
497+
->setIsUnchallengedToken(true);
497498
}
498499

499500
$this->request = $request;

‎src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -5152,12 +5152,14 @@ private function requireMFA(PhabricatorLiskDAO $object, array $xactions) {
51525152
'an MFA check.'));
51535153
}
51545154

5155-
id(new PhabricatorAuthSessionEngine())
5155+
$token = id(new PhabricatorAuthSessionEngine())
51565156
->setWorkflowKey($workflow_key)
51575157
->requireHighSecurityToken($actor, $request, $cancel_uri);
51585158

5159-
foreach ($xactions as $xaction) {
5160-
$xaction->setIsMFATransaction(true);
5159+
if (!$token->getIsUnchallengedToken()) {
5160+
foreach ($xactions as $xaction) {
5161+
$xaction->setIsMFATransaction(true);
5162+
}
51615163
}
51625164
}
51635165

0 commit comments

Comments
 (0)
Failed to load comments.