| 1 | <?php |
| 2 | // error reporting (for testing) |
| 3 | ini_set('display_errors', 1); error_reporting(E_ALL); |
| 4 | |
| 5 | // Read DB settings |
| 6 | $dbdata = json_decode(file_get_contents('/etc/kairo/auth_db.json'), true); |
| 7 | if (!is_array($dbdata)) { trigger_error('DB configuration not found', E_USER_ERROR); } |
| 8 | |
| 9 | $pwd_options = array('cost' => 10); |
| 10 | |
| 11 | // Extended DOM document class |
| 12 | require_once('../kairo/include/cbsm/util/document.php-class'); |
| 13 | // Class for sending emails |
| 14 | require_once('../kairo/include/classes/email.php-class'); |
| 15 | |
| 16 | bindtextdomain('kairo_auth', 'en'); // XXX: Should negotiate locale. |
| 17 | bind_textdomain_codeset('kairo_auth', 'utf-8'); |
| 18 | |
| 19 | // Connect to our MySQL DB |
| 20 | $db = new PDO($dbdata['dsn'], $dbdata['username'], $dbdata['password']); |
| 21 | |
| 22 | /* Creating the DB tables: |
| 23 | CREATE TABLE `auth_sessions` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT , `sesskey` VARCHAR(150) NOT NULL DEFAULT '' , `user` MEDIUMINT UNSIGNED NULL DEFAULT NULL , `logged_in` BOOLEAN NOT NULL DEFAULT FALSE , `time_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `time_expire` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY (`id`), INDEX (`sesskey`), INDEX (`time_expire`)); |
| 24 | CREATE TABLE `auth_users` ( `id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT , `email` VARCHAR(255) NOT NULL , `pwdhash` VARCHAR(255) NOT NULL , `status` ENUM('unverified','ok') NOT NULL DEFAULT 'unverified' , `verify_hash` VARCHAR(150) NULL DEFAULT NULL , PRIMARY KEY (`id`), UNIQUE (`email`)); |
| 25 | */ |
| 26 | |
| 27 | // include our OAuth2 Server object |
| 28 | require_once(__DIR__.'/server.inc.php'); |
| 29 | ?> |