Path: blob/master/src/applications/auth/storage/PhabricatorAuthFactorConfig.php
12256 views
<?php123final class PhabricatorAuthFactorConfig4extends PhabricatorAuthDAO5implements6PhabricatorPolicyInterface,7PhabricatorDestructibleInterface {89protected $userPHID;10protected $factorProviderPHID;11protected $factorName;12protected $factorSecret;13protected $properties = array();1415private $sessionEngine;16private $factorProvider = self::ATTACHABLE;17private $mfaSyncToken;1819protected function getConfiguration() {20return array(21self::CONFIG_SERIALIZATION => array(22'properties' => self::SERIALIZATION_JSON,23),24self::CONFIG_AUX_PHID => true,25self::CONFIG_COLUMN_SCHEMA => array(26'factorName' => 'text',27'factorSecret' => 'text',28),29self::CONFIG_KEY_SCHEMA => array(30'key_user' => array(31'columns' => array('userPHID'),32),33),34) + parent::getConfiguration();35}3637public function getPHIDType() {38return PhabricatorAuthAuthFactorPHIDType::TYPECONST;39}4041public function attachFactorProvider(42PhabricatorAuthFactorProvider $provider) {43$this->factorProvider = $provider;44return $this;45}4647public function getFactorProvider() {48return $this->assertAttached($this->factorProvider);49}5051public function setSessionEngine(PhabricatorAuthSessionEngine $engine) {52$this->sessionEngine = $engine;53return $this;54}5556public function getSessionEngine() {57if (!$this->sessionEngine) {58throw new PhutilInvalidStateException('setSessionEngine');59}6061return $this->sessionEngine;62}6364public function setMFASyncToken(PhabricatorAuthTemporaryToken $token) {65$this->mfaSyncToken = $token;66return $this;67}6869public function getMFASyncToken() {70return $this->mfaSyncToken;71}7273public function getAuthFactorConfigProperty($key, $default = null) {74return idx($this->properties, $key, $default);75}7677public function setAuthFactorConfigProperty($key, $value) {78$this->properties[$key] = $value;79return $this;80}8182public function newSortVector() {83return id(new PhutilSortVector())84->addInt($this->getFactorProvider()->newStatus()->getOrder())85->addInt($this->getID());86}878889/* -( PhabricatorPolicyInterface )----------------------------------------- */909192public function getCapabilities() {93return array(94PhabricatorPolicyCapability::CAN_VIEW,95PhabricatorPolicyCapability::CAN_EDIT,96);97}9899public function getPolicy($capability) {100return $this->getUserPHID();101}102103public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {104return false;105}106107108/* -( PhabricatorDestructibleInterface )----------------------------------- */109110111public function destroyObjectPermanently(112PhabricatorDestructionEngine $engine) {113114$user = id(new PhabricatorPeopleQuery())115->setViewer($engine->getViewer())116->withPHIDs(array($this->getUserPHID()))117->executeOne();118119$this->delete();120121if ($user) {122$user->updateMultiFactorEnrollment();123}124}125126}127128129