KaiRo bug 412 - Use composer to load oauth2-server-php and doctrine DBAL
authorRobert Kaiser <kairo@kairo.at>
Thu, 15 Dec 2016 13:57:44 +0000 (14:57 +0100)
committerRobert Kaiser <kairo@kairo.at>
Thu, 15 Dec 2016 13:57:44 +0000 (14:57 +0100)
.gitignore
app/authsystem.inc.php
app/authutils.php-class
app/server.inc.php
composer.json [new file with mode: 0644]

index a79011c0349440f0860597e946735413091c9629..1533c81471a46abb36265513cd6a887c47480fea 100644 (file)
@@ -1,3 +1,4 @@
 *~
-/oauth2-server-php
+composer.lock
+/vendor
 /php-utility-classes
index d098af07e76c320a1a4c706b4da8ad813a634c6b..45d0e0fb64fb78e84594e27c9b3aab7fe5fa620f 100644 (file)
@@ -20,16 +20,22 @@ $settings = json_decode(file_get_contents('/etc/kairo/auth_settings.json'), true
 if (!is_array($settings)) { trigger_error('Auth settings not found', E_USER_ERROR); }
 
 // Extended DOM document class
-require_once('../php-utility-classes/classes/document.php-class');
+require_once(__DIR__.'/../php-utility-classes/classes/document.php-class');
 // Class for sending emails
-require_once('../php-utility-classes/classes/email.php-class');
-// Class for sending emails
-require_once(__DIR__.'/authutils.php-class');
-
+require_once(__DIR__.'/../php-utility-classes/classes/email.php-class');
+// Composer-provided libraries (oauth2-server-php, doctrine DBAL)
+require_once(__DIR__.'/../vendor/autoload.php');
 // Connect to our MySQL DB
 $db = new PDO($dbdata['dsn'], $dbdata['username'], $dbdata['password']);
-// Instantiate auth utils.
-$utils = new AuthUtils($settings, $db);
+// Authentication utilities
+require_once(__DIR__.'/authutils.php-class');
+// Instantiate server utils.
+try {
+  $utils = new AuthUtils($settings, $db);
+}
+catch (Exception $e) {
+  $utils = null;
+}
 
 // This is an array of locale tags in browser style mapping to unix system locale codes to use with gettext.
 $supported_locales = array(
index db5dd891a27754f1bf906ed8f6464f031c575d41..42f585910458ca7f5f516c3f76cce2432d6f7c49 100755 (executable)
@@ -34,6 +34,9 @@ class AuthUtils {
   // function checkForSecureConnection()
   //   Check is the connection is secure and return an array of error messages (empty if it's secure).
   //
+  // function sendSecurityHeaders()
+  //   Rend HTTP headers for improving security.
+  //
   // function initSession()
   //   Initialize a session. Returns an associative array of all the DB fields of the session.
   //
index 87b6535d4132b694d008bf3076caf794d8596963..53e55b467835180bce98c78033d5a5177fe81d5e 100644 (file)
@@ -7,10 +7,6 @@
 
 // $dbata needs to be set and be an associative array with the members 'dsn', 'username', and 'password'.
 
-// Autoloading (composer is preferred, but for this example let's just do this)
-require_once('../oauth2-server-php/src/OAuth2/Autoloader.php');
-OAuth2\Autoloader::register();
-
 // $dsn is the Data Source Name for your database, for exmaple "mysql:dbname=my_oauth2_db;host=localhost"
 $oauth2_storage = new OAuth2\Storage\Pdo($dbdata);
 
diff --git a/composer.json b/composer.json
new file mode 100644 (file)
index 0000000..a448d97
--- /dev/null
@@ -0,0 +1,6 @@
+{
+"require": {
+  "doctrine/dbal": "v2.5.5",
+  "bshaffer/oauth2-server-php": "~1.8"
+}
+}
\ No newline at end of file