本文整理汇总了PHP中Auth_OpenID类的典型用法代码示例。如果您正苦于以下问题:PHP Auth_OpenID类的具体用法?PHP Auth_OpenID怎么用?PHP Auth_OpenID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth_OpenID类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: make_request
function make_request()
{
//get openid identifier URL
if (empty($_GET['openid_url'])) {
$error = "Expected an OpenID URL.";
print $error;
exit(0);
}
$openid = $_GET['openid_url'];
$consumer = get_consumer();
//begin openid authentication
$auth_request = $consumer->begin($openid);
//no authentication available
if (!$auth_request) {
print "Authentication error; not a valid OpenID.";
}
//add openid extensions to the request
$auth_request->addExtension(attach_ax());
//attribute exchange
//generate redirect url
$return_url = sprintf("%s%s", APP_ROOT, FILE_COMPLETE);
$trust_root = sprintf("http://%s%s/", $_SERVER['SERVER_NAME'], dirname($_SERVER['PHP_SELF']));
$redirect_url = $auth_request->redirectURL($trust_root, $return_url);
//attach oauth extension parameters to redirect url
$hybrid_fields = array('openid.ns.oauth' => 'http://specs.openid.net/extensions/oauth/1.0', 'openid.oauth.consumer' => CONSUMER_KEY);
$redirect_url .= '&' . http_build_query($hybrid_fields);
//if no redirect available display error message, else redirect
if (Auth_OpenID::isFailure($redirect_url)) {
print "Could not redirect to server: " . $redirect_url->message;
} else {
header("Location: " . $redirect_url);
}
}
开发者ID:spaceone,项目名称:programming-social-applications,代码行数:33,代码来源:auth.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: 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
示例5: try_auth
public function try_auth($openid)
{
$url = HttpRequest::getPathUrl();
$nb = strlen($url);
$base_url = '';
if ($nb == 0 || $url[$nb - 1] != "/") {
$base_url = "http://" . $_SERVER['HTTP_HOST'] . $url . "/";
} else {
$base_url = "http://" . $_SERVER['HTTP_HOST'] . $url;
}
$trust_root = $base_url;
$return_url = $base_url . 'index.php/openid/finish_auth';
$store = new WMySqlStore(DbUtil::accessFactory());
$store->createTables();
$consumer =& new Auth_OpenID_Consumer($store);
// Begin the OpenID authentication process.
$auth_request = $consumer->begin($openid);
// No auth request means we can't begin OpenID.
if (!$auth_request) {
$_SESSION['isError'] = true;
$_SESSION['message'] = __("Authentication error; not a valid OpenID.");
DefaultFC::redirection('users/index');
exit;
}
// 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($trust_root, $return_url);
// If the redirect URL can't be built, display an error
// message.
if (Auth_OpenID::isFailure($redirect_url)) {
$_SESSION['isError'] = true;
$_SESSION['message'] = __("Could not redirect to server: ") . $redirect_url->message;
DefaultFC::redirection('users/index');
exit;
} else {
// Send redirect.
header("Location: " . $redirect_url);
}
} else {
// Generate form markup and render it.
$form_id = 'openid_message';
$form_html = $auth_request->htmlMarkup($trust_root, $return_url, 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)) {
$_SESSION['isError'] = true;
$_SESSION['message'] = __("Could not redirect to server: ") . $form_html->message;
DefaultFC::redirection('users/index');
exit;
} else {
print $form_html;
}
}
}
开发者ID:ripplecrpht,项目名称:ripplecrpht,代码行数:58,代码来源:Openid.class.php
示例6: issueOpenid2Connexion
private function issueOpenid2Connexion(Auth_OpenID_AuthRequest $auth_request, $redirect_url)
{
$form_id = "openid_message";
$form_html = $auth_request->htmlMarkup($this->getTrustRoot(), $this->getReturnTo($redirect_url), false, array('id' => $form_id));
if (Auth_OpenID::isFailure($form_html)) {
throw new OpenId_OpenIdException($GLOBALS['Language']->getText('plugin_openid', 'error_openid_connect'));
}
echo $form_html;
}
开发者ID:pombredanne,项目名称:tuleap,代码行数:9,代码来源:ConnexionDriver.class.php
示例7: add
/**
* takes an associative array and adds OpenID
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Core_BAO_OpenID object on success, null otherwise
* @access public
* @static
*/
static function add(&$params)
{
$openId =& new CRM_Core_DAO_OpenID();
// normalize the OpenID URL
require_once 'Auth/OpenID.php';
$params['openid'] = Auth_OpenID::normalizeURL($params['openid']);
$openId->copyValues($params);
return $openId->save();
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:18,代码来源:OpenID.php
示例8: run
function run()
{
$openid = getOpenIDURL();
$consumer = getConsumer();
$return_to = getReturnTo();
// 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.");
}
// add AX request
if ($_GET['ax'] == 'true') {
$ax_request = new Auth_OpenID_AX_FetchRequest();
global $ax_data;
foreach ($ax_data as $ax_key => $ax_data_ns) {
// set AX params
if ($_GET['ax_' . $ax_key] == 'true') {
$ax_request->add(new Auth_OpenID_AX_AttrInfo($ax_data_ns, 1, true, $ax_key));
}
}
// add extension
if ($ax_request) {
$auth_request->addExtension($ax_request);
}
}
// add UI extension request
if ($_GET['ui'] == 'true') {
$UI_request = new OpenID_UI_Request();
// set icon
if ($_GET['icon'] == 'true') {
$UI_request->setIcon();
}
// set lang
if ($_GET['lang'] == 'true' && $_GET['pref_lang']) {
$UI_request->setLang($_GET['pref_lang']);
}
// set popup
if ($_GET['popup'] == 'true') {
$UI_request->setPopup();
$return_to .= "popup=true";
}
$auth_request->addExtension($UI_request);
} else {
if ($_GET['callback'] == "ax") {
$return_to .= "callback=ax";
}
}
$redirect_url = $auth_request->redirectURL(getTrustRoot(), $return_to);
if (Auth_OpenID::isFailure($redirect_url)) {
displayError("Could not redirect to server: " . $redirect_url->message);
} else {
// Send redirect.
header("Location: " . $redirect_url);
}
}
开发者ID:ritou,项目名称:php-openid-popup-example,代码行数:56,代码来源:try_auth.php
示例9: test_cryptrand
function test_cryptrand()
{
// It's possible, but HIGHLY unlikely that a correct
// implementation will fail by returning the same number twice
$s = Auth_OpenID_CryptUtil::getBytes(32);
$t = Auth_OpenID_CryptUtil::getBytes(32);
$this->assertEquals(Auth_OpenID::bytes($s), 32);
$this->assertEquals(Auth_OpenID::bytes($t), 32);
$this->assertFalse($s == $t);
}
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:10,代码来源:CryptUtil.php
示例10: xorSecret
function xorSecret($composite, $secret, $hash_func)
{
$dh_shared = $this->getSharedSecret($composite);
$dh_shared_str = $this->lib->longToBinary($dh_shared);
$hash_dh_shared = $hash_func($dh_shared_str);
$xsecret = "";
for ($i = 0; $i < Auth_OpenID::bytes($secret); $i++) {
$xsecret .= chr(ord($secret[$i]) ^ ord($hash_dh_shared[$i]));
}
return $xsecret;
}
开发者ID:kbjr,项目名称:EasyOpenID,代码行数:11,代码来源:DiffieHellman.php
示例11: canFetchURL
/**
* Return whether a URL can be fetched. Returns false if the URL
* scheme is not allowed or is not supported by this fetcher
* implementation; returns true otherwise.
*
* @return bool
*/
function canFetchURL($url)
{
if ($this->isHTTPS($url) && !$this->supportsSSL()) {
Auth_OpenID::log("HTTPS URL unsupported fetching %s", $url);
return false;
}
if (!$this->allowedURL($url)) {
Auth_OpenID::log("URL fetching not allowed for '%s'", $url);
return false;
}
return true;
}
开发者ID:openid,项目名称:php-openid,代码行数:19,代码来源:HTTPFetcher.php
示例12: Auth_OpenID_HMACSHA1
/**
* Compute an HMAC/SHA1 hash.
*
* @access private
* @param string $key The HMAC key
* @param string $text The message text to hash
* @return string $mac The MAC
*/
function Auth_OpenID_HMACSHA1($key, $text)
{
if (Auth_OpenID::bytes($key) > Auth_OpenID_SHA1_BLOCKSIZE) {
$key = Auth_OpenID_SHA1($key, true);
}
$key = str_pad($key, Auth_OpenID_SHA1_BLOCKSIZE, chr(0x0));
$ipad = str_repeat(chr(0x36), Auth_OpenID_SHA1_BLOCKSIZE);
$opad = str_repeat(chr(0x5c), Auth_OpenID_SHA1_BLOCKSIZE);
$hash1 = Auth_OpenID_SHA1(($key ^ $ipad) . $text, true);
$hmac = Auth_OpenID_SHA1(($key ^ $opad) . $hash1, true);
return $hmac;
}
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:20,代码来源:HMAC.php
示例13: _requestAssociation
function _requestAssociation($endpoint, $assoc_type, $session_type)
{
$m = array_pop($this->return_messages);
if (is_a($m, 'Auth_OpenID_Message')) {
return Auth_OpenID_ServerErrorContainer::fromMessage($m);
} else {
if (Auth_OpenID::isFailure($m)) {
return $m;
} else {
return $m;
}
}
}
开发者ID:openid,项目名称:php-openid,代码行数:13,代码来源:Negotiation.php
示例14: 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
示例15: action_default
/**
* Handle a standard OpenID server request
*/
function action_default()
{
global $store;
$server =& getServer();
$method = $_SERVER['REQUEST_METHOD'];
/*$request = null;
if ($method == 'GET') {
$request = $_GET;
} else {
$request = $_POST;
} */
$request = $server->decodeRequest();
if (!$request) {
return "";
//about_render();
}
setRequestInfo($request);
if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) {
$identity = getLoggedInUser();
if (isTrusted($identity, $request->trust_root, $request->return_to)) {
if ($request->message->isOpenID1()) {
$response =& $request->answer(true);
} else {
$response =& $request->answer(true, false, getServerURL(), $identity);
}
} else {
if ($request->immediate) {
$response =& $request->answer(false, getServerURL());
} else {
if (!getLoggedInUser()) {
$_SESSION['last_forward_from'] = current_page_url() . '?' . http_build_query(Auth_OpenID::getQuery());
system_message(elgg_echo('openid_server:not_logged_in'));
forward('login');
}
return trust_render($request);
}
}
addSregFields(&$response);
} else {
$response =& $server->handleRequest($request);
}
$webresponse =& $server->encodeResponse($response);
foreach ($webresponse->headers as $k => $v) {
header("{$k}: {$v}");
}
header(header_connection_close);
print $webresponse->body;
exit(0);
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:52,代码来源:actions.php
示例16: 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
示例17: fromSuccessResponse
function fromSuccessResponse(&$success_response, $signed_only = true)
{
$obj = new Auth_OpenID_OAuthResponse();
$obj->ns_uri = Auth_OpenID_OAUTH_NS_URI;
if ($signed_only) {
$args = $success_response->getSignedNS($obj->ns_uri);
} else {
$args = $success_response->message->getArgs($obj->ns_uri);
}
if ($args === null || Auth_OpenID::isFailure($args)) {
return null;
}
$obj->authorized_request_token = new OAuthToken($args['request_token'], '');
return $obj;
}
开发者ID:utopszkij,项目名称:keszlet,代码行数:15,代码来源:OAuth.php
示例18: 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
示例19: 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
示例20: openid_redirect
/**
* Send the user to their OpenID provider to authenticate.
*
* @param Auth_OpenID_AuthRequest $auth_request OpenID authentication request object
* @param string $trust_root OpenID trust root
* @param string $return_to URL where the OpenID provider should return the user
*/
function openid_redirect($auth_request, $trust_root, $return_to)
{
do_action('openid_redirect', $auth_request, $trust_root, $return_to);
$message = $auth_request->getMessage($trust_root, $return_to, false);
if (Auth_OpenID::isFailure($message)) {
return openid_error('Could not redirect to server: ' . $message->message);
}
$_SESSION['openid_return_to'] = $message->getArg(Auth_OpenID_OPENID_NS, 'return_to');
// send 302 redirect or POST
if ($auth_request->shouldSendRedirect()) {
$redirect_url = $auth_request->redirectURL($trust_root, $return_to);
wp_redirect($redirect_url);
} else {
openid_repost($auth_request->endpoint->server_url, $message->toPostArgs());
}
}
开发者ID:andrewfandrew,项目名称:bronze-boar,代码行数:23,代码来源:consumer.php
注:本文中的Auth_OpenID类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论