Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/factor/PhabricatorDuoAuthFactor.php
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | return array( | ||||
->setCredentials($credentials), | ->setCredentials($credentials), | ||||
id(new PhabricatorSelectEditField()) | id(new PhabricatorSelectEditField()) | ||||
->setLabel(pht('Duo Username')) | ->setLabel(pht('Duo Username')) | ||||
->setKey('duo.usernames') | ->setKey('duo.usernames') | ||||
->setValue($usernames) | ->setValue($usernames) | ||||
->setTransactionType($xaction_usernames) | ->setTransactionType($xaction_usernames) | ||||
->setOptions( | ->setOptions( | ||||
array( | array( | ||||
'username' => pht('Use Phabricator Username'), | 'username' => pht( | ||||
'Use %s Username', | |||||
PlatformSymbols::getPlatformServerName()), | |||||
'email' => pht('Use Primary Email Address'), | 'email' => pht('Use Primary Email Address'), | ||||
)), | )), | ||||
id(new PhabricatorSelectEditField()) | id(new PhabricatorSelectEditField()) | ||||
->setLabel(pht('Create Accounts')) | ->setLabel(pht('Create Accounts')) | ||||
->setKey('duo.enroll') | ->setKey('duo.enroll') | ||||
->setValue($enroll) | ->setValue($enroll) | ||||
->setTransactionType($xaction_enroll) | ->setTransactionType($xaction_enroll) | ||||
->setOptions( | ->setOptions( | ||||
▲ Show 20 Lines • Show All 360 Lines • ▼ Show 20 Lines | foreach ($devices as $device) { | ||||
} | } | ||||
} | } | ||||
if (!$has_push) { | if (!$has_push) { | ||||
return $this->newResult() | return $this->newResult() | ||||
->setIsError(true) | ->setIsError(true) | ||||
->setErrorMessage( | ->setErrorMessage( | ||||
pht( | pht( | ||||
'This factor has been removed from your device, so Phabricator '. | 'This factor has been removed from your device, so this server '. | ||||
'can not send you a challenge. To continue, an administrator '. | 'can not send you a challenge. To continue, an administrator '. | ||||
'must strip this factor from your account.')); | 'must strip this factor from your account.')); | ||||
} | } | ||||
$push_info = array( | $push_info = array( | ||||
pht('Domain') => $this->getInstallDisplayName(), | pht('Domain') => $this->getInstallDisplayName(), | ||||
); | ); | ||||
$push_info = phutil_build_http_querystring($push_info); | $push_info = phutil_build_http_querystring($push_info); | ||||
Show All 20 Lines | $result = $this->newDuoFuture($provider) | ||||
->setMethod('auth', $parameters) | ->setMethod('auth', $parameters) | ||||
->resolve(); | ->resolve(); | ||||
$duo_xaction = $result['response']['txid']; | $duo_xaction = $result['response']['txid']; | ||||
// The Duo push timeout is 60 seconds. Set our challenge to expire slightly | // The Duo push timeout is 60 seconds. Set our challenge to expire slightly | ||||
// more quickly so that we'll re-issue a new challenge before Duo times out. | // more quickly so that we'll re-issue a new challenge before Duo times out. | ||||
// This should keep users away from a dead-end where they can't respond to | // This should keep users away from a dead-end where they can't respond to | ||||
// Duo but Phabricator won't issue a new challenge yet. | // Duo but we won't issue a new challenge yet. | ||||
$ttl_seconds = 55; | $ttl_seconds = 55; | ||||
return array( | return array( | ||||
$this->newChallenge($config, $viewer) | $this->newChallenge($config, $viewer) | ||||
->setChallengeKey($duo_xaction) | ->setChallengeKey($duo_xaction) | ||||
->setChallengeTTL(PhabricatorTime::getNow() + $ttl_seconds), | ->setChallengeTTL(PhabricatorTime::getNow() + $ttl_seconds), | ||||
); | ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 309 Lines • Show Last 20 Lines |