From 6c56861d339035ef5399b0839262b0285721d45c Mon Sep 17 00:00:00 2001 From: blsaws Date: Tue, 14 Jun 2016 14:45:25 -0700 Subject: Further fixes to authentication JIRA: COPPER-4 Change-Id: I7e42b4847faf2658bd8bce0857473929a635c092 Signed-off-by: blsaws --- .../congress/test-webapp/setup/install_congress_testserver.sh | 1 + components/congress/test-webapp/www/proxy/index.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/congress/test-webapp/setup/install_congress_testserver.sh b/components/congress/test-webapp/setup/install_congress_testserver.sh index 9145c98..7826007 100644 --- a/components/congress/test-webapp/setup/install_congress_testserver.sh +++ b/components/congress/test-webapp/setup/install_congress_testserver.sh @@ -92,6 +92,7 @@ source /tmp/copper/env.sh echo "Point proxy.php to the Congress server" sed -i -- "s/CONGRESS_HOST/$CONGRESS_HOST/g" /tmp/copper/copper/components/congress/test-webapp/www/proxy/index.php echo "Add parameters for API authentication" +sed -i -- "s/KEYSTONE_HOST/$KEYSTONE_HOST/g" /tmp/copper/copper/components/congress/test-webapp/www/proxy/index.php sed -i -- "s/OS_USERNAME/$OS_USERNAME/g" /tmp/copper/copper/components/congress/test-webapp/www/proxy/index.php sed -i -- "s/OS_PASSWORD/$OS_PASSWORD/g" /tmp/copper/copper/components/congress/test-webapp/www/proxy/index.php diff --git a/components/congress/test-webapp/www/proxy/index.php b/components/congress/test-webapp/www/proxy/index.php index ed0b6e7..6374275 100644 --- a/components/congress/test-webapp/www/proxy/index.php +++ b/components/congress/test-webapp/www/proxy/index.php @@ -35,8 +35,14 @@ if ($result === false) { curl_setopt($curlop, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); $body = '{"auth": {"passwordCredentials": {"username": "OS_USERNAME", "password": "OS_PASSWORD"}}}'; curl_setopt($curlop, CURLOPT_POSTFIELDS, $body); + $req_time=time(); + $result = file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$url.", ".$type.", ".$body."\n",FILE_APPEND); + if ($result === false) $response = "PHP error in index.php"; $response = curl_exec($curlop); - $response = json_decode($response); + $body = substr($response, $header_size); + $result = file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$responseCode.", ".$type.", ".$header.", ".$body."\n",FILE_APPEND); + if ($result === false) $response = "PHP error in index.php"; + $response = json_decode($body); $token = $response->access->token->id; file_put_contents("/tmp/os_token",$token); } -- cgit 1.2.3-korg