コード例 #1
0
 private function processDelete(AphrontRequest $request, PhabricatorUserSSHKey $key)
 {
     $user = $request->getUser();
     $name = phutil_escape_html($key->getName());
     if ($request->isDialogFormPost()) {
         $key->delete();
         return id(new AphrontReloadResponse())->setURI($this->getPanelURI());
     }
     $dialog = id(new AphrontDialogView())->setUser($user)->addHiddenInput('delete', $key->getID())->setTitle('Really delete SSH Public Key?')->appendChild('<p>The key "<strong>' . $name . '</strong>" will be permanently deleted, ' . 'and you will not longer be able to use the corresponding private key ' . 'to authenticate.</p>')->addSubmitButton('Delete Public Key')->addCancelButton($this->getPanelURI());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
コード例 #2
0
ファイル: ssh-auth-key.php プロジェクト: denghp/phabricator
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$cert = file_get_contents('php://stdin');
if (!$cert) {
    exit(1);
}
$parts = preg_split('/\\s+/', $cert);
if (count($parts) < 2) {
    exit(1);
}
list($type, $body) = $parts;
$user_dao = new PhabricatorUser();
$ssh_dao = new PhabricatorUserSSHKey();
$conn_r = $user_dao->establishConnection('r');
$row = queryfx_one($conn_r, 'SELECT userName FROM %T u JOIN %T ssh ON u.phid = ssh.userPHID
    WHERE ssh.keyType = %s AND ssh.keyBody = %s', $user_dao->getTableName(), $ssh_dao->getTableName(), $type, $body);
if (!$row) {
    exit(1);
}
$user = idx($row, 'userName');
if (!$user) {
    exit(1);
}
if (!PhabricatorUser::validateUsername($user)) {
    exit(1);
}
$bin = $root . '/bin/ssh-exec';
$cmd = csprintf('%s --phabricator-ssh-user %s', $bin, $user);
// This is additional escaping for the SSH 'command="..."' string.
コード例 #3
0
ファイル: ssh-auth.php プロジェクト: denghp/phabricator
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$user_dao = new PhabricatorUser();
$ssh_dao = new PhabricatorUserSSHKey();
$conn_r = $user_dao->establishConnection('r');
$rows = queryfx_all($conn_r, 'SELECT userName, keyBody, keyType FROM %T u JOIN %T ssh
    ON u.phid = ssh.userPHID', $user_dao->getTableName(), $ssh_dao->getTableName());
if (!$rows) {
    echo pht('No keys found.') . "\n";
    exit(1);
}
$bin = $root . '/bin/ssh-exec';
foreach ($rows as $row) {
    $user = $row['userName'];
    $cmd = csprintf('%s --phabricator-ssh-user %s', $bin, $user);
    // This is additional escaping for the SSH 'command="..."' string.
    $cmd = addcslashes($cmd, '"\\');
    // Strip out newlines and other nonsense from the key type and key body.
    $type = $row['keyType'];
    $type = preg_replace('@[\\x00-\\x20]+@', '', $type);
    $key = $row['keyBody'];
    $key = preg_replace('@[\\x00-\\x20]+@', '', $key);
    $options = array('command="' . $cmd . '"', 'no-port-forwarding', 'no-X11-forwarding', 'no-agent-forwarding', 'no-pty');
    $options = implode(',', $options);
    $lines[] = $options . ' ' . $type . ' ' . $key . "\n";
}
echo implode('', $lines);
exit(0);
コード例 #4
0
 private function processDelete(AphrontRequest $request, PhabricatorUserSSHKey $key)
 {
     $viewer = $request->getUser();
     $user = $this->getUser();
     $name = phutil_tag('strong', array(), $key->getName());
     if ($request->isDialogFormPost()) {
         $key->delete();
         return id(new AphrontReloadResponse())->setURI($this->getPanelURI());
     }
     $dialog = id(new AphrontDialogView())->setUser($viewer)->addHiddenInput('delete', $key->getID())->setTitle(pht('Really delete SSH Public Key?'))->appendChild(phutil_tag('p', array(), pht('The key "%s" will be permanently deleted, and you will not longer be ' . 'able to use the corresponding private key to authenticate.', $name)))->addSubmitButton(pht('Delete Public Key'))->addCancelButton($this->getPanelURI());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }