예제 #1
0
 /**
  * testing getTrustedSites
  *
  */
 public function testGetTrustedSites()
 {
     $storage = new Zend_OpenId_Provider_Storage_File(dirname(__FILE__) . "/_files/provider");
     $storage->delUser(self::USER);
     $this->_user->delLoggedInUser();
     $provider = new Zend_OpenId_Provider(null, null, $this->_user, $storage);
     $sreg = new Zend_OpenId_Extension_Sreg(array("nickname" => "test_id"));
     $this->assertTrue($provider->register(self::USER, self::PASSWORD));
     $this->assertTrue($provider->login(self::USER, self::PASSWORD));
     $this->assertTrue($provider->allowSite("http://www.test1.com/"));
     $this->assertTrue($provider->allowSite("http://www.test2.com/", $sreg));
     $this->AssertSame(array('http://www.test1.com/' => true, 'http://www.test2.com/' => array('Zend_OpenId_Extension_Sreg' => array('nickname' => 'test_id'))), $provider->getTrustedSites());
     $this->_user->delLoggedInUser();
     $this->AssertFalse($provider->getTrustedSites());
     $storage->delUser(self::USER);
 }
예제 #2
0
 */
$dir = realpath(__DIR__ . "/../../..");
set_include_path("{$dir}/library" . PATH_SEPARATOR . get_include_path());
/**
 * @see Zend_OpenId_Provider
 */
require_once "Zend/OpenId/Provider.php";
/**
 * @see Zend_OpenId_Extension_Sreg
 */
require_once "Zend/OpenId/Extension/Sreg.php";
/**
 * @see Zend_Session_Namespace
 */
require_once "Zend/Session/Namespace.php";
$server = new Zend_OpenId_Provider();
/**
 * trust_form
 *
 * @param  string $site
 * @param  array|boolean $trusted
 * @return string
 */
function trust_form($site, $trusted)
{
    if (is_array($trusted)) {
        $str = "";
        if (isset($trusted['Zend_OpenId_Extension_Sreg'])) {
            $trusted = $trusted['Zend_OpenId_Extension_Sreg'];
            foreach ($trusted as $key => $val) {
                $str .= "{$key}:\"{$val}\";";
예제 #3
0
<?php

OCP\App::checkAppEnabled('user_openid_provider');
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/3rdparty');
require_once 'Zend/OpenId/Provider.php';
if (!isset($_REQUEST['openid_mode'])) {
    OC_Template::printGuestPage('user_openid_provider', 'main');
    die;
}
$session = new OC_OpenIdProviderUserSession();
$storage = new OC_OpenIdProviderStorage();
$server = new Zend_OpenId_Provider(null, null, $session, $storage);
if (OCP\User::isLoggedIn() and !$session->getLoggedInUser()) {
    $session->setLoggedInUser(OCP\Util::linkToAbsolute('', '?') . OCP\User::getUser());
}
if (isset($_GET['openid_action']) and $_GET['openid_action'] == 'login') {
    unset($_GET['openid_action']);
    $params = '?' . Zend_OpenId::paramsToQuery($_GET);
    $next = OCP\Util::linkToRemote('openid_provider') . $params;
    $loginPage = OCP\Util::linkToAbsolute('', 'index.php') . '?redirect_url=' . urlencode($next);
    header('Location: ' . $loginPage);
} else {
    if (isset($_GET['openid_action']) and $_GET['openid_action'] == 'trust') {
        OCP\User::checkLoggedIn();
        if (isset($_POST['allow'])) {
            if (isset($_POST['forever'])) {
                $server->allowSite($server->getSiteRoot($_GET));
            }
            $server->respondToConsumer($_GET);
        } else {
            if (isset($_POST['deny'])) {