Changeset View
Changeset View
Standalone View
Standalone View
scripts/ssh/ssh-auth-key.php
#!/usr/bin/env php | #!/usr/bin/env php | ||||
<?php | <?php | ||||
$root = dirname(dirname(dirname(__FILE__))); | $root = dirname(dirname(dirname(__FILE__))); | ||||
require_once $root.'/scripts/__init_script__.php'; | require_once $root.'/scripts/__init_script__.php'; | ||||
try { | try { | ||||
$cert = file_get_contents('php://stdin'); | $cert = file_get_contents('php://stdin'); | ||||
$public_key = PhabricatorAuthSSHPublicKey::newFromRawKey($cert); | $public_key = PhabricatorAuthSSHPublicKey::newFromRawKey($cert); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
exit(1); | exit(1); | ||||
} | } | ||||
$key = id(new PhabricatorAuthSSHKeyQuery()) | $key = id(new PhabricatorAuthSSHKeyQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withKeys(array($public_key)) | ->withKeys(array($public_key)) | ||||
->withIsActive(true) | |||||
->executeOne(); | ->executeOne(); | ||||
if (!$key) { | if (!$key) { | ||||
exit(1); | exit(1); | ||||
} | } | ||||
$object = $key->getObject(); | $object = $key->getObject(); | ||||
if (!($object instanceof PhabricatorUser)) { | if (!($object instanceof PhabricatorUser)) { | ||||
exit(1); | exit(1); | ||||
Show All 17 Lines |