Skip to content

Commit

Permalink
Updating new authentication method X-Auth-Token
Browse files Browse the repository at this point in the history
  • Loading branch information
lmartin-voxbeam committed Jun 20, 2016
1 parent b2aa678 commit 958edf1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Configuration.php
Expand Up @@ -9,7 +9,10 @@

class Configuration {
//The base Uri for API calls
public static $BASEURI = 'https://api.magictelecom.com';
public static $USERNAME = 'user@magictelecom.com';
public static $APITOKEN = '3l239fjshgshldw89323h2hdshsljdns056bm656jdbf3';
public static $BASEURI = 'http://bundles.magictelecom.dev/app_dev.php';
//The username for API Auth. I you specify username "X-WSSE" auth method gonna be used,
//if not, "X-Auth-Token" will be used.
// public static $USERNAME = 'admin@magictelecom.com';
//The API Token for authentication
public static $APITOKEN = 'thisismysupperduppersecrettoken';
}
12 changes: 11 additions & 1 deletion src/CustomAuthUtility.php
Expand Up @@ -18,7 +18,17 @@ class CustomAuthUtility {
public static function appendCustomAuthParams($request)
{
$arrHeaders = $request->__get('headers');
$arrAuthHeader = array("X-WSSE" => self::generateWSSEHeader(Configuration::$USERNAME, Configuration::$APITOKEN));
if (isset(Configuration::$USERNAME) && isset(Configuration::$APITOKEN))
{
var_dump("X-WSSE");
$arrAuthHeader = array("X-WSSE" => self::generateWSSEHeader(Configuration::$USERNAME, Configuration::$APITOKEN));
}
elseif(isset (Configuration::$APITOKEN))
{
var_dump("X-Auth-Token");
$arrAuthHeader = array("X-Auth-Token" => Configuration::$APITOKEN);
}


$arrHeaders = array_merge($arrHeaders, $arrAuthHeader);

Expand Down

0 comments on commit 958edf1

Please sign in to comment.