1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00

Support Spaces in Passphrase

Summary: Ref T8493. This stuff mostly takes care of itself now.

Test Plan: Shifted stuff between spaces, verified transactions/headers showed up correctly. Queried by space.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T8493

Differential Revision: https://secure.phabricator.com/D13386
This commit is contained in:
epriestley 2015-06-22 11:28:54 -07:00
parent 85af4b01b9
commit e6b7f655ee
4 changed files with 26 additions and 4 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_passphrase.passphrase_credential
ADD spacePHID VARBINARY(64);

View file

@ -4781,6 +4781,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
'PhabricatorSpacesInterface',
),
'PassphraseCredentialAuthorPolicyRule' => 'PhabricatorPolicyRule',
'PassphraseCredentialConduitController' => 'PassphraseController',

View file

@ -60,6 +60,7 @@ final class PassphraseCredentialEditController extends PassphraseController {
$e_name = true;
$v_desc = $credential->getDescription();
$v_space = $credential->getSpacePHID();
$v_username = $credential->getUsername();
$e_username = true;
@ -93,6 +94,7 @@ final class PassphraseCredentialEditController extends PassphraseController {
$v_is_locked = $request->getStr('lock');
$v_secret = $request->getStr('secret');
$v_space = $request->getStr('spacePHID');
$v_password = $request->getStr('password');
$v_decrypt = $v_secret;
@ -127,6 +129,7 @@ final class PassphraseCredentialEditController extends PassphraseController {
$type_is_locked = PassphraseCredentialTransaction::TYPE_LOCK;
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
$type_space = PhabricatorTransactions::TYPE_SPACE;
$xactions = array();
@ -146,6 +149,10 @@ final class PassphraseCredentialEditController extends PassphraseController {
->setTransactionType($type_edit_policy)
->setNewValue($v_edit_policy);
$xactions[] = id(new PassphraseCredentialTransaction())
->setTransactionType($type_space)
->setNewValue($v_space);
// Open a transaction in case we're writing a new secret; this limits
// the amount of code which handles secret plaintexts.
$credential->openTransaction();
@ -244,13 +251,13 @@ final class PassphraseCredentialEditController extends PassphraseController {
->setValue($type->getCredentialTypeName()))
->appendChild(
id(new AphrontFormDividerControl()))
->appendChild(
->appendControl(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
->setPolicyObject($credential)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicies($policies))
->appendChild(
->appendControl(
id(new AphrontFormPolicyControl())
->setName('editPolicy')
->setPolicyObject($credential)

View file

@ -4,7 +4,8 @@ final class PassphraseCredential extends PassphraseDAO
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
PhabricatorDestructibleInterface,
PhabricatorSpacesInterface {
protected $name;
protected $credentialType;
@ -18,6 +19,7 @@ final class PassphraseCredential extends PassphraseDAO
protected $isLocked = 0;
protected $allowConduit = 0;
protected $authorPHID;
protected $spacePHID;
private $secret = self::ATTACHABLE;
@ -37,7 +39,8 @@ final class PassphraseCredential extends PassphraseDAO
->setIsDestroyed(0)
->setAuthorPHID($actor->getPHID())
->setViewPolicy($view_policy)
->setEditPolicy($edit_policy);
->setEditPolicy($edit_policy)
->setSpacePHID($actor->getDefaultSpacePHID());
}
public function getMonogram() {
@ -158,4 +161,13 @@ final class PassphraseCredential extends PassphraseDAO
$this->delete();
$this->saveTransaction();
}
/* -( PhabricatorSpacesInterface )----------------------------------------- */
public function getSpacePHID() {
return $this->spacePHID;
}
}