• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Auth_OpenID_SRegRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Auth_OpenID_SRegRequest的典型用法代码示例。如果您正苦于以下问题:PHP Auth_OpenID_SRegRequest类的具体用法?PHP Auth_OpenID_SRegRequest怎么用?PHP Auth_OpenID_SRegRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Auth_OpenID_SRegRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getSregRequest

 public function getSregRequest($required, $optional)
 {
     $sregService = new Auth_OpenID_SRegRequest();
     $sregRequest = $sregService->build($required, $optional);
     if ($sregRequest) {
         return $sregRequest;
     }
 }
开发者ID:fisherTW,项目名称:stat-monitor,代码行数:8,代码来源:authController.php


示例2: authenticate

 /**
  * @throws InvalidArgumentException if an invalid OpenID was provided
  */
 public function authenticate($url, $return, $realm, $required = array(), $optional = array())
 {
     if (empty($realm)) {
         $realm = 'http' . (env('HTTPS') ? 's' : '') . '://' . env('SERVER_NAME');
     }
     if (trim($url) != '') {
         $consumer = $this->_consumer();
         $authRequest = $consumer->begin($url);
     }
     if (!isset($authRequest) || !$authRequest) {
         throw new InvalidArgumentException('Invalid OpenID');
     }
     $sregRequest = Auth_OpenID_SRegRequest::build($required, $optional);
     if ($sregRequest) {
         $authRequest->addExtension($sregRequest);
     }
     if (!$authRequest->shouldSendRedirect()) {
         $formId = 'openid_message';
         $formHtml = $authRequest->formMarkup($realm, $return, false, array('id' => $formId));
         if (Auth_OpenID::isFailure($formHtml)) {
             throw new Exception('Could not redirect to server: ' . $formHtml->message);
         }
         echo '<html><head><title>OpenID transaction in progress</title></head>' . "<body onload='document.getElementById(\"{$formId}\").submit()'>" . $formHtml . '</body></html>';
         exit;
     }
     $redirectUrl = $authRequest->redirectUrl($realm, $return);
     if (Auth_OpenID::isFailure($redirectUrl)) {
         throw new Exception('Could not redirect to server: ' . $redirectUrl->message);
     }
     $this->_controller->redirect($redirectUrl, null, true);
 }
开发者ID:predominant,项目名称:CakeFest-Berlin-2009-Workshop,代码行数:34,代码来源:open_id.php


示例3: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Create attribute request object
    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
    // Usage: make($type_uri, $count=1, $required=false, $alias=null)
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, 1, 'email');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname');
    // Create AX fetch request
    $ax = new Auth_OpenID_AX_FetchRequest();
    // Add attributes to AX fetch request
    foreach ($attribute as $attr) {
        $ax->add($attr);
    }
    $auth_request->addExtension($ax);
    $policy_uris = $_GET['policies'];
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:umbecr,项目名称:camilaframework,代码行数:60,代码来源:openid_try_auth.php


示例4: authenticate

 function authenticate($openId)
 {
     $consumer = $this->_getConsumer();
     $authRequest = $consumer->begin($openId);
     // No auth request means we can't begin OpenID.
     if (!$authRequest) {
         $this->_set_message(true, 'openid_auth_error');
     }
     if ($this->sreg_enable) {
         $sreg_request = Auth_OpenID_SRegRequest::build($this->sreg_required, $this->sreg_optional, $this->sreg_policy);
         if ($sreg_request) {
             $authRequest->addExtension($sreg_request);
         } else {
             $this->_set_message(true, 'openid_sreg_failed');
         }
     }
     if ($this->pape_enable) {
         $pape_request = new Auth_OpenID_PAPE_Request($this->pape_policy_uris);
         if ($pape_request) {
             $authRequest->addExtension($pape_request);
         } else {
             $this->_set_message(true, 'openid_pape_failed');
         }
     }
     if ($this->ext_args != null) {
         foreach ($this->ext_args as $extensionArgument) {
             if (count($extensionArgument) == 3) {
                 $authRequest->addExtensionArg($extensionArgument[0], $extensionArgument[1], $extensionArgument[2]);
             }
         }
     }
     // Redirect the user to the OpenID server for authentication.
     // Store the token for this authentication so we can verify the
     // response.
     // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
     // form to send a POST request to the server.
     if ($authRequest->shouldSendRedirect()) {
         $redirect_url = $authRequest->redirectURL($this->trust_root, $this->request_to);
         // If the redirect URL can't be built, display an error
         // message.
         if (Auth_OpenID::isFailure($redirect_url)) {
             $this->_set_message(true, 'openid_redirect_failed', $redirect_url->message);
         } else {
             // Send redirect.
             header("Location: " . $redirect_url);
         }
     } else {
         // Generate form markup and render it.
         $form_id = 'openid_message';
         $form_html = $authRequest->formMarkup($this->trust_root, $this->request_to, false, array('id' => $form_id));
         // Display an error if the form markup couldn't be generated;
         // otherwise, render the HTML.
         if (Auth_OpenID::isFailure($form_html)) {
             $this->_set_message(true, 'openid_redirect_failed', $form_html->message);
         } else {
             $page_contents = array("<html><head><title>", "OpenID transaction in progress", "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
             print implode("\n", $page_contents);
         }
     }
 }
开发者ID:ksakinala-c,项目名称:Styler,代码行数:60,代码来源:Openid.php


示例5: validateIdentifier

 public function validateIdentifier($validator, $values, $arguments = array())
 {
     $authRequest = $this->getAuthAdapter()->getConsumer()->begin($values['openid_identifier']);
     if (!$authRequest) {
         throw new sfValidatorError($validator, 'Authentication error: not a valid OpenID.');
     }
     $sregExchange = new opOpenIDProfileExchange('sreg');
     $authRequest->addExtension(Auth_OpenID_SRegRequest::build(array(), $sregExchange->getImportSupportedProfiles()));
     // for OpenID1
     if ($authRequest->shouldSendRedirect()) {
         $values['redirect_url'] = $authRequest->redirectURL($arguments['realm'], $arguments['return_to']);
         if (Auth_OpenID::isFailure($values['redirect_url'])) {
             throw new sfValidatorError($validator, 'Could not redirect to the server: ' . $values['redirect_url']->message);
         }
     } else {
         $axExchange = new opOpenIDProfileExchange('ax');
         $axRequest = new Auth_OpenID_AX_FetchRequest();
         foreach ($axExchange->getImportSupportedProfiles() as $key => $value) {
             $axRequest->add(Auth_OpenID_AX_AttrInfo::make($value, 1, false, 'profile_' . $key));
         }
         $authRequest->addExtension($axRequest);
         $values['redirect_html'] = $authRequest->htmlMarkup($arguments['realm'], $arguments['return_to']);
         if (Auth_OpenID::isFailure($values['redirect_html'])) {
             throw new sfValidatorError($validator, 'Could not redirect to the server: ' . $values['redirect_html']->message);
         }
     }
     return $values;
 }
开发者ID:nise-nabe,项目名称:opAuthOpenIDPlugin,代码行数:28,代码来源:opAuthLoginFormOpenID.class.php


示例6: GetSRegDataForRequest

 public function GetSRegDataForRequest(User $user)
 {
     require_once 'Auth/OpenID/SReg.php';
     // Other common SReg fields we could fill are:
     //   dob, country, language, timezone.
     $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($this->request);
     return Auth_OpenID_SRegResponse::extractResponse($sreg_request, array('fullname' => $user->fullName(), 'nickname' => $user->displayName(), 'email' => $user->bestEmail(), 'gender' => $user->isFemale() ? 'F' : 'M'));
 }
开发者ID:Ekleog,项目名称:platal,代码行数:8,代码来源:openid.inc.php


示例7: openid_server_sreg_post_auth

/**
 * See if the OpenID authentication request includes SReg and add additional hooks if so.
 */
function openid_server_sreg_post_auth($request)
{
    $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
    if ($sreg_request) {
        $GLOBALS['openid_server_sreg_request'] = $sreg_request;
        add_action('openid_server_trust_form', 'openid_server_sreg_trust_form');
        add_action('openid_server_trust_submit', 'openid_server_sreg_trust_submit', 10, 2);
        add_filter('openid_server_store_trusted_site', 'openid_server_sreg_store_trusted_site');
        add_action('openid_server_auth_response', 'openid_server_sreg_auth_response');
    }
}
开发者ID:alx,项目名称:pressid,代码行数:14,代码来源:server_ext.php


示例8: runTry

 private function runTry()
 {
     $openid = $this->getOpenIDUrl();
     $consumer = $this->getConsumer();
     $auth_request = $consumer->begin($openid);
     // No auth request means we can't begin OpenID.
     if (!$auth_request) {
         displayError("Authentication error; not a valid OpenID.");
     }
     $sreg_request = \Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
     if ($sreg_request) {
         $auth_request->addExtension($sreg_request);
     }
     $policy_uris = null;
     if (isset($_GET['policies'])) {
         $policy_uris = $_GET['policies'];
     }
     $pape_request = new \Auth_OpenID_PAPE_Request($policy_uris);
     if ($pape_request) {
         $auth_request->addExtension($pape_request);
     }
     // Redirect the user to the OpenID server for authentication.
     // Store the token for this authentication so we can verify the
     // response.
     // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
     // form to send a POST request to the server.
     if ($auth_request->shouldSendRedirect()) {
         $redirect_url = $auth_request->redirectURL($this->getTrustRoot(), $this->getReturnTo());
         // If the redirect URL can't be built, display an error
         // message.
         if (\Auth_OpenID::isFailure($redirect_url)) {
             displayError("Could not redirect to server: " . $redirect_url->message);
         } else {
             // Send redirect.
             //header("Location: ".$redirect_url);
             return Response::redirect($redirect_url);
         }
     } else {
         // Generate form markup and render it.
         $form_id = 'openid_message';
         $form_html = $auth_request->htmlMarkup($this->getTrustRoot(), $this->getReturnTo(), false, array('id' => $form_id));
         // Display an error if the form markup couldn't be generated;
         // otherwise, render the HTML.
         if (\Auth_OpenID::isFailure($form_html)) {
             displayError("Could not redirect to server: " . $form_html->message);
         } else {
             print $form_html;
         }
     }
     return null;
 }
开发者ID:catlabinteractive,项目名称:accounts,代码行数:51,代码来源:OpenIDAuthenticator.php


示例9: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("认证错误,不是有效的OpenID。");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname', 'email'), array('gender'));
    //'nickname','fullname', 'email', 'dob','gender','postcode','country','language','timezone'
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    /*NOTE:目前还很少有网站要用到PAPE这个功能
       $policy_uris = $_GET['policies'];
    
        $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
        if ($pape_request) {
            $auth_request->addExtension($pape_request);
        }
    	*/
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("不能跳转到: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("不能跳转到: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:AlexChien,项目名称:ey_uhome,代码行数:51,代码来源:try_auth.php


示例10: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError(_CORE_OID_URL_INVALID);
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname', 'email'), array('fullname', 'dob', 'gender', 'postcode', 'country', 'language', 'timezone'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = isset($_GET['policies']) ? filter_var($_GET['policies'], FILTER_SANITIZE_URL) : NULL;
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            //displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header('Location: ' . $redirect_url);
            exit;
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), FALSE, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError(sprintf(_CORE_OID_REDIRECT_FAILED, $form_html->message));
        } else {
            $page_contents = array("<html><head><title>", _CORE_OID_INPROGRESS, "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
            print implode("\n", $page_contents);
        }
    }
}
开发者ID:LeeGlendenning,项目名称:formulize,代码行数:49,代码来源:try_auth.php


示例11: authInitAction

 /**
  * @Route("/login", name="progrupa_3dwarehouse_auth_init")
  * @Template
  */
 public function authInitAction(Request $request)
 {
     if ($request->getMethod() == Request::METHOD_POST) {
         $openid = $request->get('sketchup_openid');
         $consumer = new \Auth_OpenID_Consumer(new \Auth_OpenID_FileStore(sys_get_temp_dir()));
         // Begin the OpenID authentication process.
         $auth_request = $consumer->begin($openid);
         // No auth request means we can't begin OpenID.
         if (!$auth_request) {
             return ['error' => "Authentication error; not a valid OpenID."];
         }
         $sreg_request = \Auth_OpenID_SRegRequest::build(['email'], []);
         if ($sreg_request) {
             $auth_request->addExtension($sreg_request);
         }
         $policy_uris = null;
         $pape_request = new \Auth_OpenID_PAPE_Request($policy_uris);
         if ($pape_request) {
             $auth_request->addExtension($pape_request);
         }
         // Redirect the user to the OpenID server for authentication.
         // Store the token for this authentication so we can verify the
         // response.
         // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
         // form to send a POST request to the server.
         if ($auth_request->shouldSendRedirect()) {
             $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
             // If the redirect URL can't be built, display an erro message.
             if (\Auth_OpenID::isFailure($redirect_url)) {
                 return ['error' => "Could not redirect to server: " . $redirect_url->message];
             } else {
                 // Send redirect.
                 return new RedirectResponse($redirect_url);
             }
         } else {
             // Generate form markup and render it.
             $form_id = 'openid_message';
             $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
             // Display an error if the form markup couldn't be generated otherwise, render the HTML.
             if (\Auth_OpenID::isFailure($form_html)) {
                 return ['error' => "Could not redirect to server: " . $form_html->message];
             } else {
                 return new Response($form_html);
             }
         }
     }
     return [];
 }
开发者ID:progrupa,项目名称:sketchup-3dwarehouse-bundle,代码行数:52,代码来源:AuthorizeController.php


示例12: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = $_GET['policies'];
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            $page_contents = array("<html><head><title>", "OpenID transaction in progress", "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
            print implode("\n", $page_contents);
        }
    }
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:48,代码来源:try_auth.php


示例13: addSregFields

function addSregFields(&$response, $info, $req_url)
{
    $username = getUsernameFromUrl($req_url);
    $user = get_user_by_username($username);
    if ($user) {
        $email = $user->email;
        $fullname = $user->name;
        $sreg_data = array('fullname' => $fullname, 'email' => $email);
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        //error_log('DEBUG:' . (string)($response->fields));
        $sreg_response->toMessage($response->fields);
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:16,代码来源:common.php


示例14: login

 public static function login(Request &$request)
 {
     Pea::begin_loose_syntax();
     require_once 'Auth/OpenID/Consumer.php';
     require_once 'Auth/OpenID/FileStore.php';
     require_once 'Auth/OpenID/SReg.php';
     require_once 'Auth/OpenID/PAPE.php';
     if ($request->in_vars('openid_url') != "" || $request->in_vars('openid_verify')) {
         Log::debug("begin openid auth: " . $request->in_vars('openid_url'));
         // OpenID Auth
         $consumer = new Auth_OpenID_Consumer(new Auth_OpenID_FileStore(work_path('openid')));
         if ($request->is_vars('openid_verify')) {
             $response = $consumer->complete($request->request_url());
             if ($response->status == Auth_OpenID_SUCCESS) {
                 return $response->getDisplayIdentifier();
             }
         } else {
             $auth_request = $consumer->begin($request->in_vars('openid_url'));
             if (!$auth_request) {
                 throw new RuntimeException('invalid openid url');
             }
             $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
             if ($sreg_request) {
                 $auth_request->addExtension($sreg_request);
             }
             if ($auth_request->shouldSendRedirect()) {
                 $redirect_url = $auth_request->redirectURL(url(), $request->request_url(false) . '?openid_verify=true');
                 if (Auth_OpenID::isFailure($redirect_url)) {
                     throw new RuntimeException("Could not redirect to server: {$redirect_url->message}");
                 } else {
                     $request->redirect($redirect_url);
                 }
             } else {
                 $form_html = $auth_request->htmlMarkup(url(), $request->request_url(false) . '?openid_verify=true', false, array('id' => 'openid_message'));
                 if (Auth_OpenID::isFailure($form_html)) {
                     throw new RuntimeException("Could not redirect to server: {$form_html->message}");
                 } else {
                     echo $form_html;
                     exit;
                 }
             }
         }
     }
     Pea::end_loose_syntax();
     return null;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:46,代码来源:OpenpearOpenIDAuth.php


示例15: doAuth

function doAuth($info, $trusted = null, $fail_cancels = false, $idpSelect = null)
{
    if (!$info) {
        // There is no authentication information, so bail
        return authCancel(null);
    }
    if ($info->idSelect()) {
        if ($idpSelect) {
            $req_url = idURL($idpSelect);
        } else {
            $trusted = false;
        }
    } else {
        $req_url = $info->identity;
    }
    $user = getLoggedInUser();
    setRequestInfo($info);
    if (!$info->idSelect() && $req_url != idURL($user)) {
        return login_render(array(), $req_url, $req_url);
    }
    $trust_root = $info->trust_root;
    if ($trusted) {
        setRequestInfo();
        $server =& getServer();
        $response =& $info->answer(true, null, $req_url);
        // Answer with some sample Simple Registration data.
        $sreg_data = array('fullname' => 'Example User', 'nickname' => 'example', 'dob' => '1970-01-01', 'email' => '[email protected]', 'gender' => 'F', 'postcode' => '12345', 'country' => 'ES', 'language' => 'eu', 'timezone' => 'America/New_York');
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        $sreg_response->toMessage($response->fields);
        // Generate a response to send to the user agent.
        $webresponse =& $server->encodeResponse($response);
        $new_headers = array();
        foreach ($webresponse->headers as $k => $v) {
            $new_headers[] = $k . ": " . $v;
        }
        return array($new_headers, $webresponse->body);
    } elseif ($fail_cancels) {
        return authCancel($info);
    } else {
        return trust_render($info);
    }
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:45,代码来源:common.php


示例16: openid_try

function openid_try($url)
{
    $store = new Auth_OpenID_MySQLStore(theDb());
    $store->createTables();
    $consumer = new Auth_OpenID_Consumer($store);
    $auth_request = $consumer->begin($url);
    if (!$auth_request) {
        $_SESSION["auth_error"] = "Error: not a valid OpenID.";
        header("Location: ./");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('email'), array('nickname', 'fullname'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Attribute Exchange (Google ignores Simple Registration)
    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
    $ax = new Auth_OpenID_AX_FetchRequest();
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, 1, 'email'));
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname'));
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname'));
    $auth_request->addExtension($ax);
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            die("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:jwssb90,项目名称:get-evidence,代码行数:44,代码来源:openid.php


示例17: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        // check for new install, if no, go to index, else goto new-install page
        require_once 'CRM/Core/BAO/UFMatch.php';
        $contactIds = CRM_Core_BAO_UFMatch::getContactIDs();
        if (count($contactIds) > 0) {
            displayError("Authentication error; not a valid OpenID.");
        } else {
            $session =& CRM_Core_Session::singleton();
            $session->set('new_install', true);
            include 'new_install.html';
            exit(1);
        }
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = null;
    if (isset($_REQUEST['policies'])) {
        $policy_uris = $_REQUEST['policies'];
    }
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
    // If the redirect URL can't be built, display an error
    // message.
    if (Auth_OpenID::isFailure($redirect_url)) {
        displayError("Could not redirect to server: " . $redirect_url->message);
    } else {
        // Send redirect.
        header("Location: " . $redirect_url);
        exit(2);
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:43,代码来源:try_auth.php


示例18: run_try_auth

function run_try_auth()
{
    global $authSource;
    $openid = $_GET['openid_url'];
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build($authSource->getRequiredAttributes(), $authSource->getOptionalAttributes());
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            header("Location: " . $redirect_url);
            // Send redirect.
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), FALSE, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated; otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            echo '<html><head><title>OpenID transaction in progress</title></head>
            		<body onload=\'document.getElementById("' . $form_id . '").submit()\'>' . $form_html . '</body></html>';
        }
    }
}
开发者ID:hukumonline,项目名称:yii,代码行数:42,代码来源:consumer.php


示例19: perform

 /**
  *  login_do action implementation.
  *
  *  @access public
  *  @return string  forward name.
  */
 public function perform()
 {
     require_once 'Auth/OpenID.php';
     require_once "Auth/OpenID/Consumer.php";
     require_once "Auth/OpenID/FileStore.php";
     require_once "Auth/OpenID/SReg.php";
     require_once "Auth/OpenID/PAPE.php";
     $store_path = $this->backend->getController()->getDirectory('tmp') . "/openid_filestore";
     $consumer = new Auth_OpenID_Consumer(new Auth_OpenID_FileStore($store_path));
     $auth_request = $consumer->begin($this->af->get('url'));
     if (!$auth_request) {
         $this->ae->add(null, "OpenID が不正です");
         return 'login';
     }
     $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array());
     if ($sreg_request) {
         $auth_request->addExtension($sreg_request);
     }
     if ($auth_request->shouldSendRedirect()) {
         $redirect_url = $auth_request->redirectURL($this->config->get('url'), $this->config->get('url') . "login_finish");
         // If the redirect URL can't be built, display an error
         // message.
         if (Auth_OpenID::isFailure($redirect_url)) {
             $this->ae->add(null, "Could not redirect to server: " . $redirect_url->message);
             return 'login';
         } else {
             return array('redirect', $redirect_url);
         }
     } else {
         // Generate form markup and render it.
         $form_html = $auth_request->formMarkup($this->config->get('url'), $this->config->get('url') . "login_finish", false, array('id' => 'openid_form'));
         // Display an error if the form markup couldn't be generated;
         // otherwise, render the HTML.
         if (Auth_OpenID::isFailure($form_html)) {
             $this->ae->add(null, "Could not redirect to server: " . $form_html->message);
             return 'login';
         } else {
             return array('login_do', $form_html);
         }
     }
     return 'login_do';
 }
开发者ID:riaf,项目名称:pastit,代码行数:48,代码来源:Do.php


示例20: begin

 private function begin($openid = NULL)
 {
     $store = new Auth_OpenID_FileStore($this->store_path);
     $consumer = new Auth_OpenID_Consumer($store);
     $auth_request = $consumer->begin($openid);
     if (!$auth_request) {
         throw new Exception(__('Authentication error: not a valid OpenID.'));
     }
     $sreg_request = Auth_OpenID_SRegRequest::build(array('email'), array('nickname', 'fullname'));
     if ($sreg_request) {
         $auth_request->addExtension($sreg_request);
     }
     $pape_request = new Auth_OpenID_PAPE_Request();
     if ($pape_request) {
         $auth_request->addExtension($pape_request);
     }
     // Build the redirect URL with the return page included
     $redirect_url = URL::site('openid/finish?return_to=' . Arr::get($_REQUEST, 'return_to', ''), TRUE);
     // Redirect the user to the OpenID server for authentication.
     // Store the token for this authentication so we can verify the response.
     // For OpenID 1, send a redirect:
     if ($auth_request->shouldSendRedirect()) {
         $redirect_url = $auth_request->redirectURL(URL::base(TRUE, TRUE), $redirect_url);
         if (Auth_OpenID::isFailure($redirect_url)) {
             throw new Exception(__('Could not redirect to server:') . ' ' . $redirect_url->message);
         }
         $this->request->redirect($redirect_url);
     } else {
         // the OpenID library will return a full html document
         // Auth_OpenID::autoSubmitHTML will wrap the form in body and html tags
         // see: mobules/openid/vendor/Auth/OpenID/Consumer.php
         $form_html = $auth_request->htmlMarkup(URL::base(TRUE, TRUE), $redirect_url, false, array('id' => 'openid_message'));
         // We just want the form HTML, so strip out the form
         $form_html = preg_replace('/^.*<html.*& 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Auth_OpenID_SRegResponse类代码示例发布时间:2022-05-23
下一篇:
PHP Auth_OpenID_Message类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap