Beispiel #1
0
 public static function setupPDO()
 {
     try {
         $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
         $pdo = new PDO(Config::get('database_dsn'), Config::get('database_user'), Config::get('database_password'), $options);
         $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
         return $pdo;
     } catch (\Exception $e) {
         \Sop\Log::error(__FILE__, __LINE__, 'Failed to setup database connection');
         throw $e;
     }
 }
Beispiel #2
0
<?php

require_once __DIR__ . '/../src/bootstrap.php';
\Sop\Database::setupRedBean();
if (\Sop\Config::get('use_sso')) {
    print "SKIP: This system is using sso.\n";
    exit;
}
// grp
$values = array(array('管理グループ'));
foreach ($values as $v) {
    R::exec('INSERT INTO `grp` (`grp_name`) VALUES (?)', $v);
}
// user
$values = array(array('admin', 'admin', crypt('admin'), '000', 1));
foreach ($values as $v) {
    R::exec('INSERT INTO `user` (`user_id`, `user_name`, `password`, `role`, `admin_flag`) VALUES (?, ?, ?, ?, ?)', $v);
}
// user_grp
$values = array(array('admin', 1));
foreach ($values as $v) {
    R::exec('INSERT INTO `user_grp` (`user_id`, `grp_id`) VALUES (?, ?)', $v);
}
Beispiel #3
0
<?php

require_once __DIR__ . '/../../src/bootstrap.php';
\Sop\Database::setupRedBean();
use InoOicClient\Flow\Basic;
// 既存の情報はリセットする。
unset($_SESSION[\Sop\Session::getSiteData('siteKey')]);
if (\Sop\Config::get('debug_pseudo_sso')) {
    $userInfo = array('sub' => \Sop\Config::get('debug_pseudo_sso_user'), 'updated_at' => 1424903837, 'email' => '*****@*****.**', 'name' => 'test user', 'family_name' => 'YAMADA', 'given_name' => 'Taro');
    $_SESSION[\Sop\Session::getSiteData('siteKey')]['sso_user_id'] = $userInfo['sub'];
    \Sop\SingleSignOn::registerInitialUser($userInfo);
    \Sop\SingleSignOn::updateUserData($userInfo);
} else {
    $flow = new Basic(Sop\SingleSignOn::getConfig());
    try {
        $userInfo = $flow->process();
        if ($userInfo['sub']) {
            $_SESSION[\Sop\Session::getSiteData('siteKey')]['sso_user_id'] = $userInfo['sub'];
        }
        \Sop\SingleSignOn::registerInitialUser($userInfo);
        \Sop\SingleSignOn::updateUserData($userInfo);
    } catch (\Exception $e) {
        $_SESSION[\Sop\Session::getSiteData('siteKey')]['sso_errors'] = array('シングル・サインオンの認証でエラーが発生しました。もう一度ログインを試してみてください。', $e->getMessage());
    }
}
session_write_close();
header('Location:' . \Sop\Session::getSiteData('pathname'));
Beispiel #4
0
<?php

error_reporting(E_ALL);
setlocale(LC_ALL, 'ja_JP.UTF-8');
date_default_timezone_set('Asia/Tokyo');
ini_set('display_errors', 0);
ini_set('log_errors', 1);
define('_MPDF_TEMP_PATH', __DIR__ . '/../../uploaded_files/tmp/mpdf_tmp');
if (!is_dir(_MPDF_TEMP_PATH)) {
    mkdir(_MPDF_TEMP_PATH);
}
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';
\Sop\Config::initialize(__DIR__ . '/../config');
function sop_exception_handler($exception)
{
    \Sop\Log::error(__FILE__, __LINE__, 'exception ' . $exception->getMessage());
}
set_exception_handler('sop_exception_handler');
if (isset($_SERVER['REMOTE_ADDR'])) {
    \Sop\Session::start();
}
Beispiel #5
0
<?php

require_once __DIR__ . '/../../src/bootstrap.php';
use InoOicClient\Flow\Basic;
if (!isset($_REQUEST['session_site_key']) || !isset($_REQUEST['pathname'])) {
    exit;
}
\Sop\Session::setSiteData('siteKey', $_REQUEST['session_site_key']);
\Sop\Session::setSiteData('pathname', $_REQUEST['pathname']);
if (\Sop\Config::get('debug_pseudo_sso')) {
    session_write_close();
    header('Location:' . 'callback');
} else {
    $flow = new Basic(Sop\SingleSignOn::getConfig());
    try {
        $uri = $flow->getAuthorizationRequestUri('openid email profile');
        session_write_close();
        header('Location: ' . $uri);
    } catch (\Exception $e) {
        printf("Exception during authorization URI creation: [%s] %s", get_class($e), $e->getMessage());
    }
}