From 2235571a8d3819de78a854e9e74174e50fc5e7db Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Sun, 7 Aug 2011 00:10:53 -0230 Subject: [PATCH] Updated Zend_Service_GitHub to use BasicAuth instead of sending raw credentials via GET parameters --- Zend/Service/GitHub.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Zend/Service/GitHub.php b/Zend/Service/GitHub.php index 6d20ab0..708ef7e 100755 --- a/Zend/Service/GitHub.php +++ b/Zend/Service/GitHub.php @@ -360,13 +360,11 @@ protected function _get($path, array $query = null, $addApiEntryPath = true) $this->_prepare($path, $addApiEntryPath); $this->_localHttpClient->setParameterGet($query); - if ($this->_authorizationInitialized && $query !== null) { - $_query = array_merge($this->_getAuthorizationCredentials(), $query); - $this->_localHttpClient->setParameterGet($_query); - } elseif (!$this->_authorizationInitialized && $query !== null) { - $this->_localHttpClient->setParameterGet($query); - } elseif ($this->_authorizationInitialized && $query == null) { - $this->_localHttpClient->setParameterGet($this->_getAuthorizationCredentials()); + if ( $this->_authorizationCredentials ) { + $this->_localHttpClient->setAuth( + $this->getLogin() . "/token", + $this->getToken() + ); } return $this->_localHttpClient->request('GET'); } @@ -381,15 +379,14 @@ protected function _get($path, array $query = null, $addApiEntryPath = true) protected function _post($path, $data = null) { $this->_prepare($path); - if ($this->_authorizationInitialized && $data !== null) { - $_data = array_merge($this->_getAuthorizationCredentials(), $data); - } elseif ($this->_authorizationInitialized && $data == null) { - $_data = $this->_getAuthorizationCredentials(); - } elseif (!$this->_authorizationInitialized && $data !== null) { - $_data = $data; + if ( $this->_authorizationCredentials ) { + $this->_localHttpClient->setAuth( + $this->getLogin() . "/token", + $this->getToken() + ); } - return $this->_performPost('POST', $_data); - } + return $this->_performPost('POST', $data); + } /** * Perform a POST or PUT *