require JS, set cookies, make parts of login flow work
[authserver.git] / authsystem.inc.php
... / ...
CommitLineData
1<?php
2// error reporting (for testing)
3ini_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);
7if (!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
12require_once('../kairo/include/cbsm/util/document.php-class');
13
14bindtextdomain('kairo_auth', 'en'); // XXX: Should negotiate locale.
15bind_textdomain_codeset('kairo_auth', 'utf-8');
16
17// Connect to our MySQL DB
18$db = new PDO($dbdata['dsn'], $dbdata['username'], $dbdata['password']);
19
20/* Creating the DB tables:
21CREATE 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`));
22CREATE 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`));
23*/
24
25// include our OAuth2 Server object
26require_once(__DIR__.'/server.inc.php');
27?>