function getOpenIDStore() { $s = new WMySqlStore(DbUtil::accessFactory()); $s->createTables(); return $s; }
public function finish_auth() { $always_trust = false; if (isset($_GET['pal_trust'])) { $always_trust = true; // we hide this parameter from the openid library unset($_GET['pal_trust']); $_SERVER['QUERY_STRING'] = str_replace('&pal_trust=true', '', $_SERVER['QUERY_STRING']); } $db = DbUtil::accessFactory(); $store = new WMySqlStore($db); $store->createTables(); $consumer =& new Auth_OpenID_Consumer($store); $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; } $return_url = $base_url . 'index.php/openid/finish_auth'; // Complete the authentication process using the server's // response. $response = $consumer->complete($return_url); $success = false; // Check the response status. if ($response->status == Auth_OpenID_CANCEL) { // This means the authentication was cancelled. $msg = __('Verification cancelled.'); } else { if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message. $msg = __("OpenID authentication failed: ") . $response->message; } else { if ($response->status == Auth_OpenID_SUCCESS) { $success = true; // This means the authentication succeeded; extract the // identity URL and Simple Registration data (if it was // returned). $openid = $response->getDisplayIdentifier(); Auth::loginByOpenid($openid); if (!Auth::isAuth()) { $success = false; $msg = __('Account not found.'); } } } } if ($success) { // for openid sso if (OPENID_SSO_MODE) { if ($always_trust) { setcookie('default_openid', $openid, time() + 60 * 60 * 24 * 30 * 12, HttpRequest::getPathUrl()); } } // Authentication process succeeded. // FIXME: log this connection // Redirection in the portal. DefaultFC::redirection('wall/index'); exit; } else { $_SESSION['isError'] = true; $_SESSION['message'] = $msg; DefaultFC::redirection('users/index'); exit; } }