Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/method/ConduitConnectConduitAPIMethod.php
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | protected function execute(ConduitAPIRequest $request) { | ||||
$client = $request->getValue('client'); | $client = $request->getValue('client'); | ||||
$client_version = (int)$request->getValue('clientVersion'); | $client_version = (int)$request->getValue('clientVersion'); | ||||
$client_description = (string)$request->getValue('clientDescription'); | $client_description = (string)$request->getValue('clientDescription'); | ||||
$client_description = id(new PhutilUTF8StringTruncator()) | $client_description = id(new PhutilUTF8StringTruncator()) | ||||
->setMaximumBytes(255) | ->setMaximumBytes(255) | ||||
->truncateString($client_description); | ->truncateString($client_description); | ||||
$username = (string)$request->getValue('user'); | $username = (string)$request->getValue('user'); | ||||
// Log the connection, regardless of the outcome of checks below. | |||||
$connection = new PhabricatorConduitConnectionLog(); | |||||
$connection->setClient($client); | |||||
$connection->setClientVersion($client_version); | |||||
$connection->setClientDescription($client_description); | |||||
$connection->setUsername($username); | |||||
$connection->save(); | |||||
switch ($client) { | switch ($client) { | ||||
case 'arc': | case 'arc': | ||||
$server_version = 6; | $server_version = 6; | ||||
$supported_versions = array( | $supported_versions = array( | ||||
$server_version => true, | $server_version => true, | ||||
// Client version 5 introduced "user.query" call | // Client version 5 introduced "user.query" call | ||||
4 => true, | 4 => true, | ||||
// Client version 6 introduced "diffusion.getlintmessages" call | // Client version 6 introduced "diffusion.getlintmessages" call | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | if ($token && $signature) { | ||||
PhabricatorAuthSession::TYPE_CONDUIT, | PhabricatorAuthSession::TYPE_CONDUIT, | ||||
$user->getPHID(), | $user->getPHID(), | ||||
$partial = false); | $partial = false); | ||||
} else { | } else { | ||||
throw new ConduitException('ERR-NO-CERTIFICATE'); | throw new ConduitException('ERR-NO-CERTIFICATE'); | ||||
} | } | ||||
return array( | return array( | ||||
'connectionID' => $connection->getID(), | 'connectionID' => mt_rand(), | ||||
'sessionKey' => $session_key, | 'sessionKey' => $session_key, | ||||
'userPHID' => $user->getPHID(), | 'userPHID' => $user->getPHID(), | ||||
); | ); | ||||
} | } | ||||
} | } |