Skip to content

Commit

Permalink
Release Version 11.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LoginRadius committed Sep 28, 2022
1 parent e848b5f commit bfac35e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@


# Version 11.4.2

Release on **September 28, 2022**

## Enhancements

- Added Referer Header Feature


# Version 11.4.1

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of library:

```
composer require loginradius/php-sdk:11.4.1
composer require loginradius/php-sdk:11.4.2
```

Include the following files in your Project Directory
Expand Down Expand Up @@ -95,6 +95,9 @@ define('USER', 'PROXY_USER'); // Replace PROXY_USER with your proxy server usern
define('PASSWORD', 'PROXY_PASSWORD'); // Replace PROXY_PASSWORD with your proxy server password.

define('API_DOMAIN', 'DEFINE_CUSTOM_API_DOMAIN'); // Custom API Domain
define('REFERER', 'DEFINE_REFERER'); // The referer header is used to determine the registration source from which the user has created the account and is synced in the RegistrationSource field for the user profile. When initializing the SDK, you can optionally specify Referer Header.


```

>Replace 'LOGINRADIUS_SITE_NAME_HERE', 'LOGINRADIUS_API_KEY_HERE' and 'LOGINRADIUS_API_SECRET_HERE' in the above code with your LoginRadius Site Name, LoginRadius API Key, and Secret.This information can be found in your LoginRadius account as described [here](https://www.loginradius.com/docs/api/v2/admin-console/platform-security/api-key-and-secret).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loginradius/php-sdk",
"description": "LoginRadius PHP SDK v11.4.1",
"description": "LoginRadius PHP SDK v11.4.2",
"keywords": ["loginradius", "phpsdk"],
"type": "library",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions demo/ajax_handler/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
//otherwise no need to define these option in configuration.
// define('API_DOMAIN', 'https://api.loginradius.com');




// The referer header is used to determine the registration source from which the user has created the account and is synced in the RegistrationSource field for the user profile. When initializing the SDK, you can optionally specify Referer Header.
//define('REFERER', 'DEFINE_REFERER');

require_once "../../src/LoginRadiusSDK/Utility/Functions.php";
require_once "../../src/LoginRadiusSDK/LoginRadiusException.php";
require_once "../../src/LoginRadiusSDK/Clients/IHttpClientInterface.php";
Expand Down
19 changes: 16 additions & 3 deletions src/LoginRadiusSDK/Clients/DefaultHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public function request($path, $queryArray = array(), $options = array())
if (defined('ORIGIN_IP') && ORIGIN_IP != "") {
$options['ORIGIN_IP'] = ORIGIN_IP;
}
if (defined('REFERER') && REFERER != "") {
if ($path == "/identity/v2/auth/register" || $path == "/identity/v2/auth/register/captcha") {
$options['Referer'] = REFERER;
}
}
if (defined('API_REQUEST_SIGNING') && API_REQUEST_SIGNING != "") {
$options['api_request_signing'] = API_REQUEST_SIGNING;
} else {
Expand Down Expand Up @@ -124,6 +129,7 @@ private function curlApiMethod($requestUrl, $options = array())
$expiryTime = isset($options['X-Request-Expires']) ? trim($options['X-Request-Expires']) : '';
$digest = isset($options['digest']) ? trim($options['digest']) : '';
$originIp = isset($options['ORIGIN_IP']) ? trim($options['ORIGIN_IP']) : '';
$referer = isset($options['Referer']) ? trim($options['Referer']) : '';

$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $requestUrl);
Expand All @@ -149,6 +155,9 @@ private function curlApiMethod($requestUrl, $options = array())
}
if($originIp!=''){
$optionsArray[]='X-Origin-IP: '. $originIp;
}
if ($referer != '') {
$optionsArray[] = 'Referer: ' . $referer;
}
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $optionsArray);
if(defined('PROTOCOL') && PROTOCOL != "" && defined('HOST') && HOST != "" && defined('PORT') && PORT != "" && defined('USER') && USER != "" && defined('PASSWORD') && PASSWORD != "") {
Expand Down Expand Up @@ -197,7 +206,8 @@ private function fsockopenApiMethod($requestUrl, $options = array())
$expiryTime = isset($options['X-Request-Expires']) ? trim($options['X-Request-Expires']) : '';
$digest = isset($options['digest']) ? trim($options['digest']) : '';
$originIp = isset($options['ORIGIN_IP']) ? trim($options['ORIGIN_IP']) : '';

$referer = isset($options['Referer']) ? trim($options['Referer']) : '';

$optionsArray = array('http' =>
array(
'method' => strtoupper($method),
Expand Down Expand Up @@ -235,7 +245,10 @@ private function fsockopenApiMethod($requestUrl, $options = array())
if($originIp != ''){
$optionsArray['http']['header'] .= "\r\n" . 'X-Origin-IP: ' . $originIp;
}

if ($referer != '') {
$optionsArray['http']['header'] .= "\r\n" . 'Referer: ' . $referer;
}

$context = stream_context_create($optionsArray);
$jsonResponse['response'] = file_get_contents($requestUrl, false, $context);
$parseHeaders = Functions::parseHeaders($http_response_header);
Expand All @@ -249,4 +262,4 @@ private function fsockopenApiMethod($requestUrl, $options = array())
}
return $jsonResponse;
}
}
}
6 changes: 5 additions & 1 deletion src/LoginRadiusSDK/Utility/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class Functions
{

const VERSION = '11.4.1';
const VERSION = '11.4.2';

private static $_apikey;
private static $_apisecret;
Expand Down Expand Up @@ -51,6 +51,10 @@ public function __construct($customizeOptions = array())
if (!defined('API_CONFIG_DOMAIN')) {
define('API_CONFIG_DOMAIN', 'https://config.lrcontent.com');
}

if (!defined('REFERER')) {
define('REFERER', 'API');
}
self::$_options = array_merge(self::$_options, $customizeOptions);
}

Expand Down

0 comments on commit bfac35e

Please sign in to comment.