public function testOobWithException()
 {
     $rpcStub = $this->rpcStubBuilder->setMethods(array('getOobCode'))->getMock();
     $rpcStub->expects($this->any())->method('getOobCode')->will($this->throwException(new Gitkit_ClientException('error-msg')));
     $gitkitClient = Gitkit_Client::createFromConfig($this->config, $rpcStub);
     $oobReq = array('action' => 'resetPassword', 'email' => '*****@*****.**', 'response' => '100');
     try {
         $gitkitClient->getOobResults('http://example.com/oob', $oobReq, '1.1.1.1');
     } catch (Gitkit_ClientException $e) {
         $this->assertEquals('error-msg', $e->getMessage());
     }
 }
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- 1: Load the Google Identity Toolkit helpers -->
<?php 
require_once __DIR__ . '/../../vendor/autoload.php';
$gitkitClient = Gitkit_Client::createFromFile(dirname(__FILE__) . '/../../gitkit/gitkit-server-config.json');
$gitkitUser = $gitkitClient->getUserInRequest();
?>
<!-- End modification 1 -->

<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
<link type=text/css rel=stylesheet href="//www.gstatic.com/authtoolkit/css/gitkit.css" />

<script type=text/javascript>
  window.google.identitytoolkit.signInButton(
    '#navbar',
    {
      widgetUrl: "/gitkit/gitkit.php",
      signOutUrl: "/gitkit/index.php"
    }
  );
</script>
</head>
<body>
<div id="navbar"></div>

<!-- 2: Print the user information if a signed in user is present -->
<p>
  <?php 
Beispiel #3
0
require 'csv.php';
define("USER_ID_CACHE_DURATION", 450);
if (!file_exists('config/config.php')) {
    die('config/config.php is not found');
}
$config = array();
include_once "config/config.php";
$app = new \Slim\Slim();
$app->config('debug', $config['debug']);
$db = new RedMap\Drivers\MySQLiDriver('UTF8');
$db->connect($config['db_user'], $config['db_password'], $config['db_name']);
$users = new Users($db);
$bidders = new Bidders($db, $users);
$publishers = new Publishers($db, $users);
$stats = new Stats($db);
$gitkitClient = Gitkit_Client::createFromFile('config/gitkit-server-config.json');
$app->get('/bidders/', function () use($app, $bidders) {
    $uiFormat = $app->request()->get('format') === 'ui';
    if (!$uiFormat) {
        $app->expires('+3 hour');
    }
    displayResultJson($app, $bidders->getAll($app, $uiFormat));
});
$app->get('/bidders/:id', function ($id) use($app, $bidders) {
    $uiFormat = $app->request()->get('format') === 'ui';
    if (!$uiFormat) {
        $app->expires('+3 hour');
    }
    displayResultJson($app, $bidders->get($app, $id, $uiFormat));
});
$app->delete('/bidders/:id', function ($id) use($app, $bidders, $users, $gitkitClient) {
Beispiel #4
0
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/identity/vendor/google/apiclient/src');
require_once __DIR__ . '/identity/vendor/autoload.php';
$gitkitClient = Gitkit_Client::createFromFile(dirname(__FILE__) . '/identity/callback-server-config.json');
$gitkitUser = $gitkitClient->getUserInRequest();
if ($gitkitUser) {
    // Example how to check the connected user mail
    // based on your domain name
    /*
    $allowed = array('mydomain.fr', 'mydomain.com');
    $email = $gitkitUser->getEmail();
    $domain = array_pop(explode('@', $email));
    if ( ! in_array($domain, $allowed)) {
      header("Location: http://localhost:8080/login");
      exit;
    }
    */
} else {
    header("Location: http://localhost:8080/login");
    exit;
}
?>
<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <h1>Logged. Welcome.</h1>
  </body>
</html>
function validate($token)
{
    $gitkitClient = Gitkit_Client::createFromFile(dirname(__FILE__) . '/../../gitkit/gitkit-server-config.json');
    return $gitkitClient->validateToken($token);
}