Changeset 2391
- Timestamp:
- 11/26/2011 5:01:07 AM (19 months ago)
- File:
-
- 1 edited
-
trunk/website/scripts/BuildServer.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/website/scripts/BuildServer.php
r2388 r2391 8 8 header(sprintf('WWW-Authenticate: Digest realm="%s",qop="auth",nonce="%s",opaque="%s"', 9 9 HTTP_DIGEST_REALM, uniqid(), md5(HTTP_DIGEST_REALM))); 10 exit;10 die('Authorisation required.'); 11 11 } 12 12 … … 35 35 } 36 36 37 //user => password38 $users = array('admin' => 'mypass', 'guest' => 'guest');39 40 37 //Challenge the client if we did not receive the digest 41 38 if (empty($_SERVER['PHP_AUTH_DIGEST'])) … … 44 41 //Analyze the PHP_AUTH_DIGEST variable 45 42 $credentials = http_digest_parse($_SERVER['PHP_AUTH_DIGEST']); 46 if (!$credentials || !isset($users[$credentials['username']]))43 if (!$credentials) 47 44 http_digest_challenge(); 48 45 49 //Check the response 50 $A1 = md5($credentials['username'] . ':' . HTTP_DIGEST_REALM . ':' . $users[$credentials['username']]); 46 //Does the user exist? 47 require_once('Credentials.php'); 48 require_once('Database.php'); 49 $database = new Database(); 50 $count = $database->query(sprintf('SELECT COUNT(*) FROM build_slaves WHERE Username=%s', 51 $database->quote($credentials['username'])))->fetch(); 52 $count = $count[0]; 53 if (!$count) 54 http_digest_challenge(); 55 56 //Check the response for the password. 57 $password = $database->query(sprintf('SELECT Password FROM build_slaves WHERE Username=%s', 58 $database->quote($credentials['username'])))->fetch(); 59 $password = $password['Password']; 60 $A1 = md5($credentials['username'] . ':' . HTTP_DIGEST_REALM . ':' . $password); 51 61 $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $credentials['uri']); 52 62 $valid_response = md5($A1 . ':' . $credentials['nonce'] . ':' . $credentials['nc'] . ':' . … … 58 68 require_once('BuildUtil.php'); 59 69 require_once('BuildBranch.php'); 60 require_once('Credentials.php');61 require_once('Database.php');62 70 63 71 try … … 65 73 //Check that we have all the necessary information 66 74 $branches = BuildBranch::Get(); 75 if (!is_numeric($_GET['revision']) || !is_numeric($_GET['filesize']) || empty($_GET['url']) || empty($_GET['branch'])) 76 throw new Exception('Invalid build information provided.'); 67 77 if (!array_key_exists($_GET['branch'], $branches)) 68 78 throw new Exception('The branch ' . $_GET['branch'] . ' does not exist.'); 69 if (!is_numeric($_GET['revision']) || !is_numeric($_GET['filesize']) || empty($_GET['url']))70 throw new Exception('Invalid build information provided.');71 79 72 80 //Get the branch the notification is for
Note: See TracChangeset
for help on using the changeset viewer.
