Last active
August 29, 2015 14:21
-
-
Save dwaghmare/bb878e4795bfef0e7109 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// All custom changes below. Modify as needed. | |
// Defines account specific settings. | |
// $ah_database_name should be the Acquia Cloud workflow database name which | |
// will store SAML session information.set | |
// You can use any database that you have defined in your workflow. | |
// Use the database "role" without the stage ("dev", "stage", or "test", etc.) | |
$ah_database_name = 'mydatabasename'; | |
// Set some security and other configs that are set above, however we | |
// overwrite them here to keep all changes in one area | |
$config['technicalcontact_name'] = "Your Name"; | |
$config['technicalcontact_email'] = "[email protected]"; | |
// Change these for your installation | |
$config['secretsalt'] = 'y0h9d13pki9qdhfm3l5nws4jjn55j6hj'; | |
$config['auth.adminpassword'] = 'mysupersecret'; | |
// Prevent Varnish from interfering with SimpleSAMLphp. | |
setcookie('NO_CACHE', '1'); | |
// Non-Acquia environments are set to "local". | |
if (empty($_ENV['AH_SITE_ENVIRONMENT'])) { | |
$_ENV['AH_SITE_ENVIRONMENT'] = 'local'; | |
} | |
// The library gets creds for the current environment dynamically. | |
if ($_ENV['AH_SITE_ENVIRONMENT'] != 'local') { | |
$creds = db_info($ah_database_name); | |
$config['store.type'] = 'sql'; | |
$config['store.sql.dsn'] = sprintf('mysql:host=%s;port=%s;dbname=%s', $creds['host'], $creds['port'], $creds['name']); | |
$config['store.sql.username'] = $creds['user']; | |
$config['store.sql.password'] = $creds['pass']; | |
$config['store.sql.prefix'] = 'simplesaml'; | |
// Set log location, as specified by Acquia | |
$config['logging.handler'] = 'file'; | |
$config['loggingdir'] = '/mnt/tmp/' . $_ENV['AH_SITE_NAME']; | |
$config['logging.logfile'] = 'simplesamlphp-' . date("Ymd") . '.log'; | |
// Set baseurlpath to be available correctly for each environment | |
$config['baseurlpath'] = 'https://'.$_SERVER["HTTP_HOST"].'/simplesaml/'; | |
} | |
else { | |
// add any local configuration here | |
} | |
function db_info($db_name) { | |
$creds_json = file_get_contents('/var/www/site-php/' . $_ENV['AH_SITE_NAME'] . '/creds.json'); | |
$databases = json_decode($creds_json, TRUE); | |
$db = $databases['databases'][$db_name]; | |
$db['host'] = ($host = ah_db_current_host($db['db_cluster_id']))?$host:key($db['db_url_ha']); | |
return $db; | |
} | |
function ah_db_current_host($db_cluster_id) { | |
require_once("/usr/share/php/Net/DNS2_wrapper.php"); | |
try { | |
$resolver = new Net_DNS2_Resolver(array('nameservers' => array('127.0.0.1', 'dns-master'))); | |
$response = $resolver->query("cluster-{$db_cluster_id}.mysql", 'CNAME'); | |
$cached_id = $response->answer[0]->cname; | |
} | |
catch (Net_DNS2_Exception $e) { | |
$cached_id = ""; | |
} | |
return $cached_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment