X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/f5bdbfca6e34e35231ab7ae72241c152b047f86b..e380a7f6aaefb1bbd16a595b6f855ce036501981:/www/login.php diff --git a/www/login.php b/www/login.php index 00d1877..e3d165d 100644 --- a/www/login.php +++ b/www/login.php @@ -18,6 +18,7 @@ set_include_path( . PATH_SEPARATOR . get_include_path() ); +$pageRequiresLogin = false; require_once 'www-header.php'; require_once 'openid/config.php'; @@ -39,7 +40,7 @@ if (!count($_GET) && !count($_POST)) { } // Hackaround Non-Javascript Login Page -if (!count($_POST) && isset($_GET['start'])) { +if (!count($_POST) && isset($_GET['openid_url'])) { $_POST = $_GET; } @@ -52,7 +53,7 @@ if (isset($_POST['openid_url'])) { } try { - $o = new OpenID_RelyingParty($returnTo, $realm, $openid_url); + $o = new \OpenID_RelyingParty($returnTo, $realm, $openid_url); } catch (OpenID_Exception $e) { $contents = "
" . $e->getMessage() . "\n"; @@ -66,10 +67,10 @@ if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associat $_SESSION['disable_associations'] = true; } -$log = new OpenID_Observer_Log; -OpenID::attach($log); +$log = new \OpenID_Observer_Log; +\OpenID::attach($log); -if (isset($_POST['start'])) { +if (isset($_POST['openid_url'])) { $_SESSION['openid_url'] = $openid_url; try { @@ -82,19 +83,13 @@ if (isset($_POST['start'])) { exit; } - // checkid_immediate - if (!empty($_POST['checkid_immediate'])) { - $authRequest->setMode('checkid_immediate'); - } - // SREG - $sreg = new OpenID_Extension_SREG11(OpenID_Extension::REQUEST); - $sreg->set('required', 'email,firstname,lastname,nickname'); - $sreg->set('optional', 'gender,dob'); + $sreg = new \OpenID_Extension_SREG11(\OpenID_Extension::REQUEST); + $sreg->set('required', 'email,fullname'); $authRequest->addExtension($sreg); // AX - $ax = new OpenID_Extension_AX(OpenID_Extension::REQUEST); + $ax = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST); $ax->set('type.email', 'http://axschema.org/contact/email'); $ax->set('type.firstname', 'http://axschema.org/namePerson/first'); $ax->set('type.lastname', 'http://axschema.org/namePerson/last'); @@ -102,117 +97,80 @@ if (isset($_POST['start'])) { $ax->set('required', 'email,firstname,lastname'); $authRequest->addExtension($ax); - // UI - if (!empty($_POST['ui'])) { - $ui = new OpenID_Extension_UI(OpenID_Extension::REQUEST); - $ui->set('mode', 'popup'); - $ui->set('language', 'en-US'); - $authRequest->addExtension($ui); - } - - // OAuth - if (!empty($_POST['oauth'])) { - $oauth = new OpenID_Extension_OAuth(OpenID_Extension::REQUEST); - $oauth->set('consumer', $_POST['oauth_consumer_key']); - $_SESSION['OAuth_consumer_key'] = $_POST['oauth_consumer_key']; - $_SESSION['OAuth_consumer_secret'] = $_POST['oauth_consumer_secret']; - - $oauth->set('scope', $_POST['oauth_scope']); - $_SESSION['OAuth_scope'] = $_POST['oauth_scope']; - - $_SESSION['OAuth_access_token_url'] = $_POST['oauth_access_token_url']; - $_SESSION['OAuth_access_token_method'] = $_POST['oauth_access_token_method']; - - $authRequest->addExtension($oauth); - } - $url = $authRequest->getAuthorizeURL(); - if (empty($_POST['debug'])) { - header("Location: $url"); - exit; - } + header("Location: $url"); + exit; +} + +if (isset($_SESSION['openid_url'])) { + $usid = $_SESSION['openid_url']; + unset($_SESSION['openid_url']); } else { - if (isset($_SESSION['openid_url'])) { - $usid = $_SESSION['openid_url']; - unset($_SESSION['openid_url']); - } else { - $usid = null; - } + $usid = null; +} - unset($_SESSION['disable_associations']); +unset($_SESSION['disable_associations']); - if (!count($_POST)) { - list(, $queryString) = explode('?', $_SERVER['REQUEST_URI']); - } else { - // I hate php sometimes - $queryString = file_get_contents('php://input'); - } +if (!count($_POST)) { + list(, $queryString) = explode('?', $_SERVER['REQUEST_URI']); +} else { + // I hate php sometimes + $queryString = file_get_contents('php://input'); +} - $message = new OpenID_Message($queryString, OpenID_Message::FORMAT_HTTP); - $id = $message->get('openid.claimed_id'); - $mode = $message->get('openid.mode'); +$message = new \OpenID_Message($queryString, \OpenID_Message::FORMAT_HTTP); +$id = $message->get('openid.claimed_id'); +$mode = $message->get('openid.mode'); - try { - $result = $o->verify(new Net_URL2($returnTo . '?' . $queryString), $message); - - if ($result->success()) { - $status = "