Add htaccess Auth

This commit is contained in:
Ganti 2021-02-12 19:06:21 +01:00
parent d967a3febe
commit 0b9eb900c2
2 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,9 @@ $proxy_base = 'https://proxy.yourdomain.org';
// this should point to the target CiviCRM system // this should point to the target CiviCRM system
$target_civicrm = 'https://your.civicrm.installation.org'; $target_civicrm = 'https://your.civicrm.installation.org';
//if CiviCRM is behind a htaccess authentication, you may set username:password. if empty no auth is used
//$target_civicrm_auth = 'username:password';
/**************************************************************** /****************************************************************
** FEATURES / DEFAULT PATHS ** ** FEATURES / DEFAULT PATHS **

View File

@ -21,6 +21,7 @@ $civiproxy_version = '0.6-dev';
*/ */
function civiproxy_redirect($url_requested, $parameters) { function civiproxy_redirect($url_requested, $parameters) {
global $target_interface; global $target_interface;
global $target_civicrm_auth;
$url = $url_requested; $url = $url_requested;
$curlSession = curl_init(); $curlSession = curl_init();
@ -52,6 +53,9 @@ function civiproxy_redirect($url_requested, $parameters) {
if (!empty($target_interface)) { if (!empty($target_interface)) {
curl_setopt($curlSession, CURLOPT_INTERFACE, $target_interface); curl_setopt($curlSession, CURLOPT_INTERFACE, $target_interface);
} }
if (isset($target_civicrm_auth) and !empty($target_civicrm_auth)) {
curl_setopt($ch, CURLOPT_USERPWD, $target_civicrm_auth);
}
if (file_exists(dirname(__FILE__).'/target.pem')) { if (file_exists(dirname(__FILE__).'/target.pem')) {
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem'); curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
} }