[opw-web] Integrate HybridAuth integration into main config.php



commit d05e88cf1f11a687c3ce8aba8bbcfb410834a529
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Mar 10 00:23:35 2014 -0400

    Integrate HybridAuth integration into main config.php
    
    Instead of requiring a separate config.php for HybridAuth, integrate
    the necessary variables into the main config.php.

 classes/class_config.php |   16 ++++++++++++++++
 classes/class_user.php   |   35 +++++++++++++++++++++++++++++++++--
 config.sample.php        |   13 +++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/classes/class_config.php b/classes/class_config.php
index a39e607..4150e07 100644
--- a/classes/class_config.php
+++ b/classes/class_config.php
@@ -17,6 +17,14 @@ class config
 
     var $enable_cache;
 
+    var $auth_openid_enabled;
+    var $auth_google_enabled;
+    var $auth_google_id;
+    var $auth_google_secret;
+    var $auth_facebook_enabled;
+    var $auth_facebook_id;
+    var $auth_facebook_secret;
+
     var $site_name;
     var $site_url;
     var $site_copyright;
@@ -90,6 +98,14 @@ class config
 
             $this->enable_cache     = isset($enable_cache) ? $enable_cache : '';
 
+            $this->auth_openid_enabled    = isset($auth_openid_enabled) ? $auth_openid_enabled : false;
+            $this->auth_google_enabled    = isset($auth_google_enabled) ? $auth_google_enabled : false;
+            $this->auth_google_id         = isset($auth_google_id) ? $auth_google_id : '';
+            $this->auth_google_secret     = isset($auth_google_secret) ? $auth_google_secret : '';
+            $this->auth_facebook_enabled  = isset($auth_facebook_enabled) ? $auth_facebook_enabled : false;
+            $this->auth_facebook_id       = isset($auth_facebook_id) ? $auth_facebook_id : '';
+            $this->auth_facebook_secret   = isset($auth_facebook_secret) ? $auth_facebook_secret : '';
+
             $this->site_name        = isset($site_name) ? $site_name : 'Pandora';
             $this->site_url         = isset($site_url ) ? $site_url  : 'https://' . $_SERVER["HTTP_HOST"];
             $this->site_copyright   = isset($site_copyright) ? $site_copyright : '&copy; 2012 KDE';
diff --git a/classes/class_user.php b/classes/class_user.php
index 10c9ae2..4c3eeb6 100644
--- a/classes/class_user.php
+++ b/classes/class_user.php
@@ -28,9 +28,40 @@ class user
     }
 
     function hybridauth() {
+        global $config;
+
         if (!isset($this->_hybridauth)) {
-            $authconfig = dirname(__FILE__) . '/../auth/config.php';
-            $this->_hybridauth = new Hybrid_Auth($authconfig);
+            $config = array(
+                // "base_url" the url that point to HybridAuth Endpoint (where index.php and config.php are 
found)
+                // Trailing slash here is mandatory
+                "base_url" => $config->site_url . "auth/",
+
+                "providers" => array (
+                     "OpenID" => array (
+                         "enabled" => $config->auth_openid_enabled,
+                     ),
+                     "Google" => array (
+                         "enabled" => true,
+                         "keys" => array (
+                             "id" => $config->auth_google_id,
+                             "secret" => $config->auth_google_secret
+                         ),
+                         "scope" => "https://www.googleapis.com/auth/userinfo.profile ".
+                                    "https://www.googleapis.com/auth/userinfo.email"; ,
+                         "access_type" => "online"
+                     ),
+                     "Facebook" => array (
+                         "enabled" => true,
+                         "keys" => array (
+                              "id" => $config->auth_facebook_id,
+                              "secret" => $config->auth_facebook_secret
+                         ),
+                         "scope" => "email"
+                     ),
+                )
+            );
+
+            $this->_hybridauth = new Hybrid_Auth($config);
         }
 
         return $this->_hybridauth;
diff --git a/config.sample.php b/config.sample.php
index 9ab3046..51758ad 100644
--- a/config.sample.php
+++ b/config.sample.php
@@ -31,6 +31,19 @@ $db_prefix = "";
 // Whether caching is turned on if Cache-Lite is installed; turn off for development
 $enable_cache = true;
 
+// Login authentication - see documentation on supported providers
+// at http://hybridauth.sourceforge.net/userguide.html for how to
+// sign-up for keys for providers that require them.
+$auth_openid_enabled = true;
+
+$auth_google_enabled = false;
+$auth_google_id = '';
+$auth_google_secret = '';
+
+$auth_facebook_enabled = true;
+$auth_facebook_id = '';
+$auth_facebook_secret = '';
+
 // Site name
 $site_name = "Outreach Program for Women";
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]