4 final class PhabricatorAuthFactorConfig
5 extends PhabricatorAuthDAO
7 PhabricatorPolicyInterface
,
8 PhabricatorDestructibleInterface
{
11 protected $factorProviderPHID;
12 protected $factorName;
13 protected $factorSecret;
14 protected $properties = array();
16 private $sessionEngine;
17 private $factorProvider = self
::ATTACHABLE
;
18 private $mfaSyncToken;
20 protected function getConfiguration() {
22 self
::CONFIG_SERIALIZATION
=> array(
23 'properties' => self
::SERIALIZATION_JSON
,
25 self
::CONFIG_AUX_PHID
=> true,
26 self
::CONFIG_COLUMN_SCHEMA
=> array(
27 'factorName' => 'text',
28 'factorSecret' => 'text',
30 self
::CONFIG_KEY_SCHEMA
=> array(
32 'columns' => array('userPHID'),
35 ) + parent
::getConfiguration();
38 public function getPHIDType() {
39 return PhabricatorAuthAuthFactorPHIDType
::TYPECONST
;
42 public function attachFactorProvider(
43 PhabricatorAuthFactorProvider
$provider) {
44 $this->factorProvider
= $provider;
48 public function getFactorProvider() {
49 return $this->assertAttached($this->factorProvider
);
52 public function setSessionEngine(PhabricatorAuthSessionEngine
$engine) {
53 $this->sessionEngine
= $engine;
57 public function getSessionEngine() {
58 if (!$this->sessionEngine
) {
59 throw new PhutilInvalidStateException('setSessionEngine');
62 return $this->sessionEngine
;
65 public function setMFASyncToken(PhabricatorAuthTemporaryToken
$token) {
66 $this->mfaSyncToken
= $token;
70 public function getMFASyncToken() {
71 return $this->mfaSyncToken
;
74 public function getAuthFactorConfigProperty($key, $default = null) {
75 return idx($this->properties
, $key, $default);
78 public function setAuthFactorConfigProperty($key, $value) {
79 $this->properties
[$key] = $value;
83 public function newSortVector() {
84 return id(new PhutilSortVector())
85 ->addInt($this->getFactorProvider()->newStatus()->getOrder())
86 ->addInt($this->getID());
90 /* -( PhabricatorPolicyInterface )----------------------------------------- */
93 public function getCapabilities() {
95 PhabricatorPolicyCapability
::CAN_VIEW
,
96 PhabricatorPolicyCapability
::CAN_EDIT
,
100 public function getPolicy($capability) {
101 return $this->getUserPHID();
104 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
109 /* -( PhabricatorDestructibleInterface )----------------------------------- */
112 public function destroyObjectPermanently(
113 PhabricatorDestructionEngine
$engine) {
115 $user = id(new PhabricatorPeopleQuery())
116 ->setViewer($engine->getViewer())
117 ->withPHIDs(array($this->getUserPHID()))
123 $user->updateMultiFactorEnrollment();