Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893969
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
6 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php b/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php
index 486ade37c2..b6723c7938 100644
--- a/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php
+++ b/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php
@@ -1,140 +1,131 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ConduitAPI_conduit_connect_Method extends ConduitAPIMethod {
public function shouldRequireAuthentication() {
return false;
}
public function getMethodDescription() {
return "Connect a session-based client.";
}
public function defineParamTypes() {
return array(
'client' => 'required string',
'clientVersion' => 'required int',
'clientDescription' => 'optional string',
'user' => 'optional string',
'authToken' => 'optional int',
'authSignature' => 'optional string',
);
}
public function defineReturnType() {
return 'dict<string, any>';
}
public function defineErrorTypes() {
return array(
"ERR-BAD-VERSION" =>
"Client/server version mismatch. Update your client.",
"ERR-UNKNOWN-CLIENT" =>
"Client is unknown.",
"ERR-UPDATE-ARC" =>
"Arcanist is now open source! Update your scripts/aliases to use ".
"'/home/engshare/devtools/arcanist/bin/arc' if you're running from ".
"a Facebook host, or see ".
"<http://www.intern.facebook.com/intern/wiki/index.php/Arcanist> for ".
"laptop instructions.",
"ERR-INVALID-USER" =>
"The username you are attempting to authenticate with is not valid.",
"ERR-INVALID-CERTIFICATE" =>
"Your authentication certificate for this server is invalid.",
"ERR-INVALID-TOKEN" =>
"The challenge token you are authenticating with is outside of the ".
"allowed time range. Either your system clock is out of whack or ".
"you're executing a replay attack.",
- "ERR-NO-CERTIFICATE" =>
- 'This server requires authentication but your client is not '.
- 'configured with an authentication certificate. For instructions on '.
- "installing Arcanist certificates, see the documentation:\n\n".
- ' http://www.phabricator.com/docs/phabricator/article/'.
- 'Installing_Arcanist_Certificates.html'.
- "\n\n".
- "Retrieve your certificate for this server by logging into the web ".
- "interface and going here:\n\n".
- ' '.PhabricatorEnv::getProductionURI('/settings/page/arcanist/'),
+ "ERR-NO-CERTIFICATE" => "This server requires authentication.",
);
}
protected function execute(ConduitAPIRequest $request) {
$client = $request->getValue('client');
$client_version = (int)$request->getValue('clientVersion');
$client_description = (string)$request->getValue('clientDescription');
$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) {
case 'arc':
$server_version = 2;
switch ($client_version) {
case 1:
throw new ConduitException('ERR-UPDATE-ARC');
case $server_version:
break;
default:
throw new ConduitException('ERR-BAD-VERSION');
}
break;
default:
// Allow new clients by default.
break;
}
$token = $request->getValue('authToken');
$signature = $request->getValue('authSignature');
$user = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$username);
if (!$user) {
throw new ConduitException('ERR-INVALID-USER');
}
$session_key = null;
if ($token && $signature) {
if (abs($token - time()) > 60 * 15) {
throw new ConduitException('ERR-INVALID-TOKEN');
}
$valid = sha1($token.$user->getConduitCertificate());
if ($valid != $signature) {
throw new ConduitException('ERR-INVALID-CERTIFICATE');
}
$session_key = $user->establishSession('conduit');
} else {
throw new ConduitException('ERR-NO-CERTIFICATE');
}
return array(
'connectionID' => $connection->getID(),
'sessionKey' => $session_key,
'userPHID' => $user->getPHID(),
);
}
}
diff --git a/src/docs/arcanist_certificates.diviner b/src/docs/arcanist_certificates.diviner
deleted file mode 100644
index 4a58185510..0000000000
--- a/src/docs/arcanist_certificates.diviner
+++ /dev/null
@@ -1,28 +0,0 @@
-@title Installing Arcanist Certificates
-@group config
-
-Arcanist uses certificates to authenticate to Phabricator. Usernames and
-certificates for each host you have credentials on are stored in your
-##~/.arcrc## file under the "hosts" key. The configuration should look something
-like this:
-
- {
- # ...
- "hosts" : {
- "http://phabricator.example.com/api/" : {
- "user" : "alincoln",
- "cert" : "Y2FTilanoONuPzAtXayoctmX6FmIt7QjxXhWVAv2EoWpeik1Deecl3jRo"
- }
- # If you have accounts on more than one host, add them here.
- }
- }
-
-To retrieve the certificate for a Phabricator host:
-
- - Login to Phabricator. **Make sure you log into the installation you are
- trying to install a certificate for!** If you are installing a certificate
- for ##phabricator.example.com##, you need to log into
- ##phabricator.example.com##, **not** ##secure.phabricator.com##.
- - Go to Settings (upper right, near Search) > Arcanist Certificate.
-
-Copy the host info including the certificate into the "hosts" section.
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 19:11 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127828
Default Alt Text
(6 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment