KaiRo bug 413 - Set up doctrine DBAL to drive the DB and do schema migration
[authserver.git] / app / authsystem.inc.php
... / ...
CommitLineData
1<?php
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6/*
7 Some resources for how to store passwords:
8 - https://blog.mozilla.org/webdev/2012/06/08/lets-talk-about-password-storage/
9 - https://wiki.mozilla.org/WebAppSec/Secure_Coding_Guidelines
10 oauth-server-php: https://bshaffer.github.io/oauth2-server-php-docs/cookbook
11*/
12
13// error reporting (for testing)
14ini_set('display_errors', 1); error_reporting(E_ALL);
15
16// Extended DOM document class
17require_once(__DIR__.'/../php-utility-classes/classes/document.php-class');
18// Class for sending emails
19require_once(__DIR__.'/../php-utility-classes/classes/email.php-class');
20// Composer-provided libraries (oauth2-server-php, doctrine DBAL)
21require_once(__DIR__.'/../vendor/autoload.php');
22// Authentication utilities
23require_once(__DIR__.'/authutils.php-class');
24// Instantiate server utils.
25try {
26 $utils = new AuthUtils();
27 $db = $utils->db;
28 $settings = $utils->settings;
29}
30catch (Exception $e) {
31 $utils = null;
32 print('Failed to set up utilities: '.$e->getMessage());
33 exit(1);
34}
35
36$utils->setUpL10n();
37
38// Sanitize settings.
39$settings['piwik_enabled'] = (@$settings['piwik_enabled']) ? true : false;
40$settings['piwik_site_id'] = intval(@$settings['piwik_site_id']);
41$settings['piwik_url'] = strlen(@$settings['piwik_url']) ? $settings['piwik_url'] : '/piwik/';
42$settings['piwik_tracker_path'] = strlen(@$settings['piwik_tracker_path']) ? $settings['piwik_tracker_path'] : '../vendor/piwik/piwik-php-tracker/';
43
44// Set up our OAuth2 Server object
45$server = $utils->getOAuthServer();
46?>