From b0687c328fcaa4d891b31c2146694654cd4707c9 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 00:43:33 -0400 Subject: Organize files into directories --- data/templates/base.htm | 6 +++--- data/templates/exception.htm | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/templates/base.htm b/data/templates/base.htm index b9c9608..2b8544b 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -4,10 +4,10 @@ - + {% block title %}{% endblock %} - {{title}} - - + + {% block meta %}{% endblock %} diff --git a/data/templates/exception.htm b/data/templates/exception.htm index dc07fc5..7a96da0 100644 --- a/data/templates/exception.htm +++ b/data/templates/exception.htm @@ -1,7 +1,7 @@ - + Error - phorkie -- cgit v1.2.3 From a73791f16d10ea0e2c477f29d9049d75516aa774 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 01:17:46 -0400 Subject: Added OpenID Authentication --- data/config.default.php | 5 + data/config.php.dist | 4 + data/templates/base.htm | 8 ++ data/templates/forbidden.htm | 21 ++++ data/templates/login.htm | 44 +++++++ src/openid/config.php | 55 +++++++++ src/openid/wrapper.php | 27 +++++ www/.htaccess | 4 + www/auth.php | 258 ++++++++++++++++++++++++++++++++++++++++ www/css/debug.css | 85 +++++++++++++ www/css/openid.css | 64 ++++++++++ www/delete.php | 3 + www/display.php | 3 + www/edit.php | 3 + www/forbidden.php | 11 ++ www/fork.php | 3 + www/images/access_denied.png | Bin 0 -> 15610 bytes www/images/google.gif | Bin 0 -> 1596 bytes www/images/openid-inputicon.gif | Bin 0 -> 237 bytes www/images/yahoo.gif | Bin 0 -> 1682 bytes www/index.php | 3 + www/list.php | 5 +- www/login.php | 11 ++ www/new.php | 3 + www/raw.php | 3 + www/revision.php | 3 + www/secure.php | 11 ++ www/www-header.php | 4 + 28 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 data/templates/forbidden.htm create mode 100644 data/templates/login.htm create mode 100644 src/openid/config.php create mode 100644 src/openid/wrapper.php create mode 100644 www/auth.php create mode 100644 www/css/debug.css create mode 100644 www/css/openid.css create mode 100644 www/forbidden.php create mode 100644 www/images/access_denied.png create mode 100644 www/images/google.gif create mode 100644 www/images/openid-inputicon.gif create mode 100644 www/images/yahoo.gif create mode 100644 www/login.php create mode 100644 www/secure.php (limited to 'data') diff --git a/data/config.default.php b/data/config.default.php index 88c9ae5..7ecbda3 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -12,6 +12,11 @@ $GLOBALS['phorkie']['cfg'] = array( 'geshi' => 'MediaWiki/geshi/geshi/geshi.php', 'index' => 'new'//"new" or "list" ); +$GLOBALS['phorkie']['auth'] = array( + 'secure' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = use authentication + 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate + 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits +); $GLOBALS['phorkie']['tools'] = array( '\\phorkie\\Tool_Xmllint' => true, '\\phorkie\\Tool_PHPlint' => true, diff --git a/data/config.php.dist b/data/config.php.dist index 1e814bd..e90f704 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -5,4 +5,8 @@ //$GLOBALS['phorkie']['cfg']['git']['private'] = 'ssh://git@bogo:paste/'; //$GLOBALS['phorkie']['cfg']['elasticsearch'] = 'http://localhost:9200/phorkie/'; //$GLOBALS['phorkie']['cfg']['setupcheck'] = false; +//$GLOBALS['phorkie']['users'] = array( +// 'https://www.google.com/accounts/o8/id?id=ABCDEFGHIJKLMNOPQRSTUVWXYZ', +// 'http://anonymous.phorkie.openid' +//); ?> diff --git a/data/templates/base.htm b/data/templates/base.htm index 2b8544b..8192b6b 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -25,6 +25,14 @@
  • List all
  • + {% if identity %} +
  • + {{name}} ({{email}}) +
  • +
  • + Logout +
  • + {% endif %} {% if db.adapter %}
  • {% if identity %}
  • - {{name}} ({{email}}) + {{name}} ({{email}})
  • Logout @@ -65,4 +65,4 @@ - \ No newline at end of file + diff --git a/data/templates/user.htm b/data/templates/user.htm new file mode 100644 index 0000000..c8ef387 --- /dev/null +++ b/data/templates/user.htm @@ -0,0 +1,15 @@ +{% extends "base.htm" %} +{% block title %}User Preferences{% endblock %} + +{% block content %} + +
    +
    + User Profile +

    Please update your git preferences for {{ identity }}

    +
    +
    + +
    +
    +{% endblock %} diff --git a/www/.htaccess b/www/.htaccess index fd2963b..c1d339d 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -23,3 +23,4 @@ RewriteRule ^search/([0-9]+)$ /search.php?page=$1 RewriteRule ^auth$ /auth.php RewriteRule ^login$ /login.php RewriteRule ^forbidden$ /forbidden.php +RewriteRule ^user$ /user.php diff --git a/www/user.php b/www/user.php new file mode 100644 index 0000000..1cc8aeb --- /dev/null +++ b/www/user.php @@ -0,0 +1,27 @@ + $_SESSION['identity'], + 'name' => $_SESSION['name'], + 'email' => $_SESSION['email'] + ) +); +?> -- cgit v1.2.3 From 5935a357efd7be14481b21560347f70116891e16 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 13:52:17 -0400 Subject: ADD: Commit as logged in user --- data/config.default.php | 1 + src/phorkie/Repository/Post.php | 14 ++++++++++---- www/edit.php | 2 +- www/new.php | 2 +- www/www-header.php | 6 ++++++ 5 files changed, 19 insertions(+), 6 deletions(-) (limited to 'data') diff --git a/data/config.default.php b/data/config.default.php index 7ecbda3..da16241 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -15,6 +15,7 @@ $GLOBALS['phorkie']['cfg'] = array( $GLOBALS['phorkie']['auth'] = array( 'secure' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = use authentication 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate + 'anonymousName' => 'Anonymous', // Email for non-authenticated commits 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits ); $GLOBALS['phorkie']['tools'] = array( diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php index de987e0..ed44cf1 100644 --- a/src/phorkie/Repository/Post.php +++ b/src/phorkie/Repository/Post.php @@ -15,7 +15,7 @@ class Repository_Post * * @return boolean True if the post was successful */ - public function process($postData) + public function process($postData, $sessionData) { if (!isset($postData['files'])) { return false; @@ -117,11 +117,17 @@ class Repository_Post } } + $commitmsg = "phorkie commit"; + if (isset($sessionData['identity'])) { + $commitmsg .= " from ".$sessionData['identity']; + } else { + $commitmsg .= " by ".$sessionData['ipaddr']; + } + if ($bCommit) { $vc->getCommand('commit') - ->setOption('message', '') - ->setOption('allow-empty-message') - ->setOption('author', 'Anonymous ') + ->setOption('message', $commitmsg) + ->setOption('author', $sessionData['name'].' <'.$sessionData['email'].'>') ->execute(); $bChanged = true; } diff --git a/www/edit.php b/www/edit.php index 226b774..db4428b 100644 --- a/www/edit.php +++ b/www/edit.php @@ -12,7 +12,7 @@ $repo = new Repository(); $repo->loadFromRequest(); $repopo = new Repository_Post($repo); -if ($repopo->process($_POST)) { +if ($repopo->process($_POST, $_SESSION)) { redirect($repo->getLink('display')); } diff --git a/www/new.php b/www/new.php index fc6d5f3..8d1a231 100644 --- a/www/new.php +++ b/www/new.php @@ -16,7 +16,7 @@ if ($GLOBALS['phorkie']['auth']['secure'] > 0) { } $repopo = new Repository_Post(); -if ($repopo->process($_POST)) { +if ($repopo->process($_POST, $_SESSION)) { redirect($repopo->repo->getLink('display')); } diff --git a/www/www-header.php b/www/www-header.php index 74863e1..5785a3e 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -47,6 +47,12 @@ if (file_exists(__DIR__ . '/../data/config.php')) { if ($GLOBALS['phorkie']['cfg']['setupcheck']) { SetupCheck::run(); } + +// Set/Get git commit session variables +$_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR']; +if (!isset($_SESSION['name'])) { $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName']; } +if (!isset($_SESSION['email'])) { $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail']; } + \Twig_Autoloader::register(); $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']); -- cgit v1.2.3 From 0845bf175dc416cdf107209fc34f7b37bf42b6e6 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 15:17:28 -0400 Subject: data/templates/revision-head.htm - ADD: display commit message --- data/templates/revision-head.htm | 1 + src/phorkie/Repository.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'data') diff --git a/data/templates/revision-head.htm b/data/templates/revision-head.htm index 132a68f..a5f7e88 100644 --- a/data/templates/revision-head.htm +++ b/data/templates/revision-head.htm @@ -10,6 +10,7 @@ revision {{repo.hash}}

    + message {{repo.message}}

    diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php index 448982b..6ed3807 100644 --- a/src/phorkie/Repository.php +++ b/src/phorkie/Repository.php @@ -32,6 +32,12 @@ class Repository */ public $hash; + /** + * Commit message of the last (or current) revision + * + * @var string + */ + public $message; /** @@ -56,6 +62,7 @@ class Repository $this->id = (int)$_GET['id']; $this->loadDirs(); $this->loadHash(); + $this->loadMessage(); } protected function loadDirs() @@ -97,6 +104,23 @@ class Repository $this->hash = $output; } + public function loadMessage() + { + $rev = (isset($this->hash)) ? $this->hash : 'HEAD'; + $output = $this->getVc()->getCommand('log') + ->setOption('oneline') + ->addArgument('-1') + ->addArgument($rev) + ->execute(); + $output = trim($output); + if (strpos($output, ' ') > 0) { + $output = substr($output, strpos($output, ' '), strlen($output)); + $this->message = trim($output); + } else { + $this->message = "This commit message intentionally left blank."; + } + } + public function loadById($id) { if (!is_numeric($id)) { -- cgit v1.2.3 From 76aa2ab76d8f2305db7a2bb7cdbe461cca0146a3 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 09:53:19 -0400 Subject: ADD: Add identity to /forbidden page for easy administration --- data/templates/forbidden.htm | 6 +++++- www/auth.php | 9 --------- www/secure.php | 8 ++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'data') diff --git a/data/templates/forbidden.htm b/data/templates/forbidden.htm index ad40a9f..e6965dd 100644 --- a/data/templates/forbidden.htm +++ b/data/templates/forbidden.htm @@ -5,7 +5,11 @@
    Access Denied - + +

    We're sorry, your identity is not authorized:

    +

    {{ identity }}

    +

    If you feel this message is in error, please notify the site admin + and include your identity.

    {% endblock %} diff --git a/www/auth.php b/www/auth.php index bb4fcb2..b8d08ff 100644 --- a/www/auth.php +++ b/www/auth.php @@ -201,15 +201,6 @@ if (isset($_POST['start'])) { } $openid = $message->getArrayFormat(); - if ($GLOBALS['phorkie']['auth']['secure'] > 0 && - $GLOBALS['phorkie']['auth']['userlist']) { - if (!in_array($openid['openid.identity'], $GLOBALS['phorkie']['users'])) { - $redirect = 'http://' . $_SERVER['HTTP_HOST'] . "/forbidden"; - header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); - exit; - } - } - // include_once 'openid/wrapper.php'; $email = (isset($openid['openid.ext1.value.email'])) ? $openid['openid.ext1.value.email'] : null; $email = (isset($openid['openid.ext2.value.email']) && !isset($email)) ? $openid['openid.ext2.value.email'] : $email; diff --git a/www/secure.php b/www/secure.php index 07cdfb6..4b81d59 100644 --- a/www/secure.php +++ b/www/secure.php @@ -9,4 +9,12 @@ if (!isset($_SESSION['identity'])) { header("Location: /login"); exit; } +if ($GLOBALS['phorkie']['auth']['secure'] > 0 && + $GLOBALS['phorkie']['auth']['userlist']) { + if (!in_array($_SESSION['identity'], $GLOBALS['phorkie']['users'])) { + $redirect = 'http://' . $_SERVER['HTTP_HOST'] . "/forbidden"; + header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); + exit; + } +} ?> -- cgit v1.2.3 From 13989a4e7cb4453225762dab6b5e5a7565b43df8 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 15:30:15 -0400 Subject: FIX: login - sreg/ax default, identifier renamed to openid_url --- data/templates/login.htm | 6 +++--- www/auth.php | 46 +++++++++++++++++++++------------------------- www/css/openid.css | 2 +- www/www-header.php | 5 ++++- 4 files changed, 29 insertions(+), 30 deletions(-) (limited to 'data') diff --git a/data/templates/login.htm b/data/templates/login.htm index 154994a..7e724b0 100644 --- a/data/templates/login.htm +++ b/data/templates/login.htm @@ -15,12 +15,12 @@

    Please choose your account provider

    - - + +

    or enter your OpenID URL.

    - +
    diff --git a/www/auth.php b/www/auth.php index 1cafd59..29d7b37 100644 --- a/www/auth.php +++ b/www/auth.php @@ -41,16 +41,16 @@ if (!count($_POST) && isset($_GET['start'])) { $_POST = $_GET; } -if (isset($_POST['identifier'])) { - $identifier = $_POST['identifier']; -} else if (isset($_SESSION['identifier'])) { - $identifier = $_SESSION['identifier']; +if (isset($_POST['openid_url'])) { + $openid_url = $_POST['openid_url']; +} else if (isset($_SESSION['openid_url'])) { + $openid_url = $_SESSION['openid_url']; } else { - $identifier = null; + $openid_url = null; } try { - $o = new OpenID_RelyingParty($returnTo, $realm, $identifier); + $o = new OpenID_RelyingParty($returnTo, $realm, $openid_url); } catch (OpenID_Exception $e) { $contents = "
    \n"; $contents .= "
    " . $e->getMessage() . "
    \n"; @@ -69,7 +69,7 @@ OpenID::attach($log); if (isset($_POST['start'])) { - $_SESSION['identifier'] = $identifier; + $_SESSION['openid_url'] = $openid_url; try { $authRequest = $o->prepare(); } catch (OpenID_Exception $e) { @@ -86,23 +86,19 @@ if (isset($_POST['start'])) { } // SREG - if (!empty($_POST['sreg'])) { - $sreg = new OpenID_Extension_SREG11(OpenID_Extension::REQUEST); - $sreg->set('required', 'email,firstname,lastname,nickname'); - $sreg->set('optional', 'gender,dob'); - $authRequest->addExtension($sreg); - } + $sreg = new OpenID_Extension_SREG11(OpenID_Extension::REQUEST); + $sreg->set('required', 'email,firstname,lastname,nickname'); + $sreg->set('optional', 'gender,dob'); + $authRequest->addExtension($sreg); // AX - if (!empty($_POST['ax'])) { - $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'); - $ax->set('mode', 'fetch_request'); - $ax->set('required', 'email,firstname,lastname'); - $authRequest->addExtension($ax); - } + $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'); + $ax->set('mode', 'fetch_request'); + $ax->set('required', 'email,firstname,lastname'); + $authRequest->addExtension($ax); // UI if (!empty($_POST['ui'])) { @@ -136,9 +132,9 @@ if (isset($_POST['start'])) { } } else { - if (isset($_SESSION['identifier'])) { - $usid = $_SESSION['identifier']; - unset($_SESSION['identifier']); + if (isset($_SESSION['openid_url'])) { + $usid = $_SESSION['openid_url']; + unset($_SESSION['openid_url']); } else { $usid = null; } diff --git a/www/css/openid.css b/www/css/openid.css index 38988a7..296618b 100644 --- a/www/css/openid.css +++ b/www/css/openid.css @@ -25,7 +25,7 @@ body { background-color: #FFFCC9; float: left; } -#identifier { +#openid_url { margin: 0px !important; width: 250px; background: #FFF url(/images/openid-inputicon.gif) no-repeat scroll 0 50%; diff --git a/www/www-header.php b/www/www-header.php index 64dca11..96cd481 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -1,6 +1,9 @@ Date: Mon, 17 Sep 2012 15:50:56 -0400 Subject: FIX: Combine auth.php to login.php --- README.rst | 3 - data/templates/login.htm | 6 +- src/openid/config.php | 2 +- www/.htaccess | 1 - www/auth.php | 216 ---------------------------------------------- www/login.php | 217 +++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 216 insertions(+), 229 deletions(-) delete mode 100644 www/auth.php (limited to 'data') diff --git a/README.rst b/README.rst index 0b40b39..b92804a 100644 --- a/README.rst +++ b/README.rst @@ -192,8 +192,6 @@ URLs Shows form for new paste ``/login`` Login page for protecting site -``/auth`` - Authentication callback url ``/user`` Edit logged-in user information @@ -236,6 +234,5 @@ If you use nginx, place the following lines into your ``server`` block: rewrite ^/search/([0-9]+)$ /search.php?page=$1; rewrite ^/login$ /login.php; - rewrite ^/auth$ /auth.php; rewrite ^/user$ /user.php; } diff --git a/data/templates/login.htm b/data/templates/login.htm index 7e724b0..418432e 100644 --- a/data/templates/login.htm +++ b/data/templates/login.htm @@ -5,7 +5,7 @@ -
    + @@ -15,8 +15,8 @@

    Please choose your account provider

    - - + +

    or enter your OpenID URL.

    diff --git a/src/openid/config.php b/src/openid/config.php index fdec5e1..76ebc6a 100644 --- a/src/openid/config.php +++ b/src/openid/config.php @@ -41,7 +41,7 @@ $returnTo = $base . dirname($_SERVER['PHP_SELF']); if ($returnTo[strlen($returnTo) - 1] != '/') { $returnTo .= '/'; } -$returnTo .= 'auth'; +$returnTo .= 'login'; // SQL storage example // $storeOptions = array( diff --git a/www/.htaccess b/www/.htaccess index f6c3720..1f03fac 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -21,6 +21,5 @@ RewriteRule ^list/([0-9]+)$ /list.php?page=$1 RewriteRule ^search$ /search.php RewriteRule ^search/([0-9]+)$ /search.php?page=$1 -RewriteRule ^auth$ /auth.php RewriteRule ^login$ /login.php RewriteRule ^user$ /user.php diff --git a/www/auth.php b/www/auth.php deleted file mode 100644 index 29d7b37..0000000 --- a/www/auth.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @copyright 2009 Bill Shupp - * @license http://www.opensource.org/licenses/bsd-license.php FreeBSD - * @link http://github.com/shupp/openid - */ - -// A tool for testing Relying Party functionality -set_include_path( - __DIR__ . '/../../src/' - . PATH_SEPARATOR . get_include_path() -); - -require_once 'www-header.php'; -require_once 'openid/config.php'; - - -if (isset($_REQUEST['logout'])) { - unset($_SESSION); - session_destroy(); - $redirect = 'http://' . $_SERVER['HTTP_HOST']; - header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); - exit; -} - -if (!count($_GET) && !count($_POST)) { - $redirect = 'http://' . $_SERVER['HTTP_HOST'] . "/login"; - header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); - exit; -} - -// Hackaround Non-Javascript Login Page -if (!count($_POST) && isset($_GET['start'])) { - $_POST = $_GET; -} - -if (isset($_POST['openid_url'])) { - $openid_url = $_POST['openid_url']; -} else if (isset($_SESSION['openid_url'])) { - $openid_url = $_SESSION['openid_url']; -} else { - $openid_url = null; -} - -try { - $o = new OpenID_RelyingParty($returnTo, $realm, $openid_url); -} catch (OpenID_Exception $e) { - $contents = "
    \n"; - $contents .= "
    " . $e->getMessage() . "
    \n"; - $contents .= "
    "; - include_once 'openid/wrapper.php'; - exit; -} - -if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associations'])) { - $o->disableAssociations(); - $_SESSION['disable_associations'] = true; -} - -$log = new OpenID_Observer_Log; -OpenID::attach($log); - -if (isset($_POST['start'])) { - - $_SESSION['openid_url'] = $openid_url; - try { - $authRequest = $o->prepare(); - } catch (OpenID_Exception $e) { - $contents = "
    \n"; - $contents .= "
    " . $e->getMessage() . "
    \n"; - $contents .= "
    "; - include_once 'openid/wrapper.php'; - 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'); - $authRequest->addExtension($sreg); - - // AX - $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'); - $ax->set('mode', 'fetch_request'); - $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; - } - -} else { - if (isset($_SESSION['openid_url'])) { - $usid = $_SESSION['openid_url']; - unset($_SESSION['openid_url']); - } else { - $usid = null; - } - - unset($_SESSION['disable_associations']); - - 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'); - - try { - $result = $o->verify(new Net_URL2($returnTo . '?' . $queryString), $message); - - if ($result->success()) { - $status = "Status:SUCCESS!"; - $status .= " ({$result->getAssertionMethod()})"; - } else { - $status = "Status:FAIL!"; - $status .= " ({$result->getAssertionMethod()})"; - } - } catch (OpenID_Exception $e) { - $status = "Status:EXCEPTION!"; - $status .= " ({$e->getMessage()} : {$e->getCode()})"; - } - - // OAuth hyprid fetching access token - if (isset($_SESSION['OAuth_consumer_key'], - $_SESSION['OAuth_consumer_secret'], - $_SESSION['OAuth_access_token_url'], - $_SESSION['OAuth_access_token_method'])) { - - try { - $oauth = new OpenID_Extension_OAuth(OpenID_Extension::RESPONSE, - $message); - - // Fix line lengths. - $consumerKey = $_SESSION['OAuth_consumer_key']; - $consumerSecret = $_SESSION['OAuth_consumer_key']; - $tokenURL = $_SESSION['OAuth_access_token_url']; - $tokenMethod = $_SESSION['OAuth_access_token_method']; - - $oauthData = $oauth->getAccessToken($consumerKey, - $consumerSecret, - $tokenURL, - array(), - $tokenMethod); - - } catch (Exception $e) { - } - } - - $openid = $message->getArrayFormat(); - - $email = (isset($openid['openid.ext1.value.email'])) ? $openid['openid.ext1.value.email'] : null; - $email = (isset($openid['openid.ext2.value.email']) && !isset($email)) ? $openid['openid.ext2.value.email'] : $email; - $email = (isset($openid['openid.sreg.email']) && !isset($email)) ? $openid['openid.sreg.email'] : $email; - $email = (isset($openid['openid.ax.value.email']) && !isset($email)) ? $openid['openid.ax.value.email'] : $email; - $_SESSION['email'] = (isset($email)) ? $email : $GLOBALS['phorkie']['auth']['anonymousEmail']; - - $name = (isset($openid['openid.ext1.value.firstname']) && isset($openid['openid.ext1.value.lastname'])) ? $openid['openid.ext1.value.firstname']." ".$openid['openid.ext1.value.lastname'] : null; - $name = (isset($openid['openid.sreg.firstname']) && isset($openid['openid.sreg.lastname']) && !isset($name)) ? $openid['openid.sreg.firstname']." ".$openid['openid.sreg.lastname'] : $name; - $name = (isset($openid['openid.sreg.nickname']) && !isset($name)) ? $openid['openid.sreg.nickname'] : $name; - $_SESSION['name'] = (isset($name)) ? $name : $_SERVER['REMOTE_ADDR']; - - $_SESSION['identity'] = $openid['openid.identity']; - - $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SESSION['REQUEST_URI']; - header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); - exit; -} - -?> diff --git a/www/login.php b/www/login.php index 87c34f4..00d1877 100644 --- a/www/login.php +++ b/www/login.php @@ -1,11 +1,218 @@ + * @copyright 2009 Bill Shupp + * @license http://www.opensource.org/licenses/bsd-license.php FreeBSD + * @link http://github.com/shupp/openid */ namespace phorkie; -require_once 'www-header.php'; -render( - 'login', - null +// A tool for testing Relying Party functionality +set_include_path( + __DIR__ . '/../../src/' + . PATH_SEPARATOR . get_include_path() ); + +require_once 'www-header.php'; +require_once 'openid/config.php'; + + +if (isset($_REQUEST['logout'])) { + unset($_SESSION); + session_destroy(); + $redirect = 'http://' . $_SERVER['HTTP_HOST']; + header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); + exit; +} + +if (!count($_GET) && !count($_POST)) { + render( + 'login', + null + ); + exit; +} + +// Hackaround Non-Javascript Login Page +if (!count($_POST) && isset($_GET['start'])) { + $_POST = $_GET; +} + +if (isset($_POST['openid_url'])) { + $openid_url = $_POST['openid_url']; +} else if (isset($_SESSION['openid_url'])) { + $openid_url = $_SESSION['openid_url']; +} else { + $openid_url = null; +} + +try { + $o = new OpenID_RelyingParty($returnTo, $realm, $openid_url); +} catch (OpenID_Exception $e) { + $contents = "
    \n"; + $contents .= "
    " . $e->getMessage() . "
    \n"; + $contents .= "
    "; + include_once 'openid/wrapper.php'; + exit; +} + +if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associations'])) { + $o->disableAssociations(); + $_SESSION['disable_associations'] = true; +} + +$log = new OpenID_Observer_Log; +OpenID::attach($log); + +if (isset($_POST['start'])) { + + $_SESSION['openid_url'] = $openid_url; + try { + $authRequest = $o->prepare(); + } catch (OpenID_Exception $e) { + $contents = "
    \n"; + $contents .= "
    " . $e->getMessage() . "
    \n"; + $contents .= "
    "; + include_once 'openid/wrapper.php'; + 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'); + $authRequest->addExtension($sreg); + + // AX + $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'); + $ax->set('mode', 'fetch_request'); + $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; + } + +} else { + if (isset($_SESSION['openid_url'])) { + $usid = $_SESSION['openid_url']; + unset($_SESSION['openid_url']); + } else { + $usid = null; + } + + unset($_SESSION['disable_associations']); + + 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'); + + try { + $result = $o->verify(new Net_URL2($returnTo . '?' . $queryString), $message); + + if ($result->success()) { + $status = "Status:SUCCESS!"; + $status .= " ({$result->getAssertionMethod()})"; + } else { + $status = "Status:FAIL!"; + $status .= " ({$result->getAssertionMethod()})"; + } + } catch (OpenID_Exception $e) { + $status = "Status:EXCEPTION!"; + $status .= " ({$e->getMessage()} : {$e->getCode()})"; + } + + // OAuth hyprid fetching access token + if (isset($_SESSION['OAuth_consumer_key'], + $_SESSION['OAuth_consumer_secret'], + $_SESSION['OAuth_access_token_url'], + $_SESSION['OAuth_access_token_method'])) { + + try { + $oauth = new OpenID_Extension_OAuth(OpenID_Extension::RESPONSE, + $message); + + // Fix line lengths. + $consumerKey = $_SESSION['OAuth_consumer_key']; + $consumerSecret = $_SESSION['OAuth_consumer_key']; + $tokenURL = $_SESSION['OAuth_access_token_url']; + $tokenMethod = $_SESSION['OAuth_access_token_method']; + + $oauthData = $oauth->getAccessToken($consumerKey, + $consumerSecret, + $tokenURL, + array(), + $tokenMethod); + + } catch (Exception $e) { + } + } + + $openid = $message->getArrayFormat(); + + $email = (isset($openid['openid.ext1.value.email'])) ? $openid['openid.ext1.value.email'] : null; + $email = (isset($openid['openid.ext2.value.email']) && !isset($email)) ? $openid['openid.ext2.value.email'] : $email; + $email = (isset($openid['openid.sreg.email']) && !isset($email)) ? $openid['openid.sreg.email'] : $email; + $email = (isset($openid['openid.ax.value.email']) && !isset($email)) ? $openid['openid.ax.value.email'] : $email; + $_SESSION['email'] = (isset($email)) ? $email : $GLOBALS['phorkie']['auth']['anonymousEmail']; + + $name = (isset($openid['openid.ext1.value.firstname']) && isset($openid['openid.ext1.value.lastname'])) ? $openid['openid.ext1.value.firstname']." ".$openid['openid.ext1.value.lastname'] : null; + $name = (isset($openid['openid.sreg.firstname']) && isset($openid['openid.sreg.lastname']) && !isset($name)) ? $openid['openid.sreg.firstname']." ".$openid['openid.sreg.lastname'] : $name; + $name = (isset($openid['openid.sreg.nickname']) && !isset($name)) ? $openid['openid.sreg.nickname'] : $name; + $_SESSION['name'] = (isset($name)) ? $name : $_SERVER['REMOTE_ADDR']; + + $_SESSION['identity'] = $openid['openid.identity']; + + $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SESSION['REQUEST_URI']; + header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); + exit; +} + ?> -- cgit v1.2.3 From 740ce67c8db40367f83248653309e69f1866b288 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 15:51:20 -0400 Subject: FIX: URL for access_denied image --- data/templates/forbidden.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/forbidden.htm b/data/templates/forbidden.htm index e6965dd..d7d3b61 100644 --- a/data/templates/forbidden.htm +++ b/data/templates/forbidden.htm @@ -5,7 +5,7 @@
    Access Denied - +

    We're sorry, your identity is not authorized:

    {{ identity }}

    If you feel this message is in error, please notify the site admin -- cgit v1.2.3 From ac41dd93568256fe5f2cd75530e30bc9b7e1668d Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 16:09:48 -0400 Subject: FIX: logout url --- data/templates/base.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/base.htm b/data/templates/base.htm index ec2b746..5681f80 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -30,7 +30,7 @@ {{name}} ({{email}})

  • - Logout + Logout
  • {% endif %} {% if db.adapter %} -- cgit v1.2.3 From dff68e21ac958ebfb8164bca4cb2143c427f4330 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 17 Sep 2012 23:01:07 +0200 Subject: use deny-by-default security --- data/templates/forbidden.htm | 26 ++++++++------------------ www/delete.php | 3 --- www/display.php | 4 +--- www/doap.php | 1 + www/edit.php | 3 --- www/forbidden.php | 11 +++++++++++ www/fork.php | 3 --- www/index.php | 7 ++++++- www/list.php | 4 +--- www/login.php | 1 + www/new.php | 4 +--- www/raw.php | 7 +++---- www/revision.php | 6 ++---- www/search.php | 1 + www/user.php | 3 --- www/www-header.php | 2 ++ www/www-security.php | 40 ++++++++++++++++++++++++++++++++++++++++ 17 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 www/forbidden.php create mode 100644 www/www-security.php (limited to 'data') diff --git a/data/templates/forbidden.htm b/data/templates/forbidden.htm index d7d3b61..04b8fb6 100644 --- a/data/templates/forbidden.htm +++ b/data/templates/forbidden.htm @@ -3,23 +3,13 @@ {% block content %} -
    - Access Denied - -

    We're sorry, your identity is not authorized:

    -

    {{ identity }}

    -

    If you feel this message is in error, please notify the site admin - and include your identity.

    -
    +acces denied +

    Access Denied

    +

    + We're sorry; but you are not allowed to access this page. +

    +

    + You may log in if you want. +

    {% endblock %} -{% block sidebar %} - {% if recents.results %} -

    Recently created

    -
      - {% for repo in recents.repos %} - {% include 'repo-sidebar-list.htm' %} - {% endfor %} -
    - {% endif %} -{% endblock %} diff --git a/www/delete.php b/www/delete.php index 85f6258..6d68ae4 100644 --- a/www/delete.php +++ b/www/delete.php @@ -4,9 +4,6 @@ namespace phorkie; * Delete paste or ask for deletion */ require_once 'www-header.php'; -if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - include_once 'secure.php'; -} $repo = new Repository(); $repo->loadFromRequest(); diff --git a/www/display.php b/www/display.php index 6f754d9..534a119 100644 --- a/www/display.php +++ b/www/display.php @@ -3,10 +3,8 @@ namespace phorkie; /** * Display paste contents */ +$pageRequiresLogin = false; require_once 'www-header.php'; -if ($GLOBALS['phorkie']['auth']['secure'] == 2) { - include_once 'secure.php'; -} $repo = new Repository(); $repo->loadFromRequest(); diff --git a/www/doap.php b/www/doap.php index db00df4..f374dba 100644 --- a/www/doap.php +++ b/www/doap.php @@ -4,6 +4,7 @@ namespace phorkie; * Display DOAP of the paste. * Contains a machine-readable project description with Git URL. */ +$pageRequiresLogin = false; require_once 'www-header.php'; $repo = new Repository(); diff --git a/www/edit.php b/www/edit.php index 20e7793..897aada 100644 --- a/www/edit.php +++ b/www/edit.php @@ -4,9 +4,6 @@ namespace phorkie; * Edit paste contents */ require_once 'www-header.php'; -if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - include_once 'secure.php'; -} $repo = new Repository(); $repo->loadFromRequest(); diff --git a/www/forbidden.php b/www/forbidden.php new file mode 100644 index 0000000..fc166eb --- /dev/null +++ b/www/forbidden.php @@ -0,0 +1,11 @@ + diff --git a/www/fork.php b/www/fork.php index 64dceb9..3d1c4b7 100644 --- a/www/fork.php +++ b/www/fork.php @@ -4,9 +4,6 @@ */ namespace phorkie; require_once 'www-header.php'; -if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - include_once 'secure.php'; -} if ($_SERVER['REQUEST_METHOD'] !== 'POST') { throw new Exception_Input('Forking only possible via POST'); diff --git a/www/index.php b/www/index.php index 7ac6fcf..1801831 100644 --- a/www/index.php +++ b/www/index.php @@ -3,6 +3,11 @@ * Jump to the index as per the configuration */ namespace phorkie; +$pageRequiresLogin = false; require_once 'www-header.php'; -require_once $GLOBALS['phorkie']['cfg']['index'].".php"; + +header( + 'Location: ' + . Tools::fullUrl('/' . $GLOBALS['phorkie']['cfg']['index']) +); ?> diff --git a/www/list.php b/www/list.php index 5a394eb..721d20c 100644 --- a/www/list.php +++ b/www/list.php @@ -3,10 +3,8 @@ * List a repository */ namespace phorkie; +$pageRequiresLogin = false; require_once 'www-header.php'; -if ($GLOBALS['phorkie']['auth']['secure'] == 2) { - include_once 'secure.php'; -} $rs = new Repositories(); $page = 0; diff --git a/www/login.php b/www/login.php index f05f980..b8cb512 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'; diff --git a/www/new.php b/www/new.php index 0675b4d..5d370f5 100644 --- a/www/new.php +++ b/www/new.php @@ -10,10 +10,8 @@ namespace phorkie; * * Creates and redirects to display page */ +$pageRequiresLogin = true; require_once 'www-header.php'; -if ($GLOBALS['phorkie']['auth']['secure'] > 0) { - include_once 'secure.php'; -} $repopo = new Repository_Post(); if ($repopo->process($_POST, $_SESSION)) { diff --git a/www/raw.php b/www/raw.php index 6b20633..634576d 100644 --- a/www/raw.php +++ b/www/raw.php @@ -1,12 +1,11 @@ loadFromRequest(); diff --git a/www/revision.php b/www/revision.php index 06462af..c4ce9e8 100644 --- a/www/revision.php +++ b/www/revision.php @@ -1,12 +1,10 @@ loadFromRequest(); diff --git a/www/search.php b/www/search.php index cb72c6a..8701911 100644 --- a/www/search.php +++ b/www/search.php @@ -3,6 +3,7 @@ namespace phorkie; /** * Search for a search term */ +$pageRequiresLogin = false; require_once 'www-header.php'; if (!isset($_GET['q']) || $_GET['q'] == '') { diff --git a/www/user.php b/www/user.php index fd851c4..8f305da 100644 --- a/www/user.php +++ b/www/user.php @@ -4,9 +4,6 @@ */ namespace phorkie; require_once 'www-header.php'; -if (!isset($_SESSION['identity'])) { - include_once 'secure.php'; -} if (isset($_POST['name'])) { $_SESSION['name'] = substr(filter_var($_POST['name'], FILTER_SANITIZE_STRING), 0, 35); diff --git a/www/www-header.php b/www/www-header.php index c840315..290e680 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -72,6 +72,8 @@ $twig = new \Twig_Environment( ); //$twig->addExtension(new \Twig_Extension_Debug()); +require __DIR__ . '/www-security.php'; + function render($tplname, $vars = array()) { $vars['css'] = $GLOBALS['phorkie']['cfg']['css']; diff --git a/www/www-security.php b/www/www-security.php new file mode 100644 index 0000000..241f866 --- /dev/null +++ b/www/www-security.php @@ -0,0 +1,40 @@ + error + require 'forbidden.php'; +} else if (isset($pageRequiresLogin) && !$pageRequiresLogin) { + return; +} + +require 'forbidden.php'; +?> \ No newline at end of file -- cgit v1.2.3 From ec100647ebe4c913ec261fddcab5004114fb5a66 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 17 Sep 2012 23:15:35 +0200 Subject: fix html validation problems --- data/templates/login.htm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/templates/login.htm b/data/templates/login.htm index 418432e..b02503f 100644 --- a/data/templates/login.htm +++ b/data/templates/login.htm @@ -15,13 +15,13 @@

    Please choose your account provider

    - - + +

    or enter your OpenID URL.

    - - + +
    -- cgit v1.2.3 From d7f8ad629a9090c2a0380f44a04049a0804cbf61 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 17 Sep 2012 23:17:03 +0200 Subject: fix another validation error --- data/templates/base.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/base.htm b/data/templates/base.htm index 5681f80..e503369 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -61,7 +61,7 @@ phorkie, the self-hosted, git-based pastebin software is available under the - AGPL. + AGPL. -- cgit v1.2.3 From e380a7f6aaefb1bbd16a595b6f855ce036501981 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 17 Sep 2012 23:33:20 +0200 Subject: get rid of start variable in form --- data/templates/login.htm | 7 ++----- www/login.php | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'data') diff --git a/data/templates/login.htm b/data/templates/login.htm index b02503f..084b438 100644 --- a/data/templates/login.htm +++ b/data/templates/login.htm @@ -6,17 +6,14 @@ - - -
    Sign-in

    Please choose your account provider

    - - + +

    or enter your OpenID URL.

    diff --git a/www/login.php b/www/login.php index 790a73a..e3d165d 100644 --- a/www/login.php +++ b/www/login.php @@ -40,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; } @@ -70,7 +70,7 @@ if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associat $log = new \OpenID_Observer_Log; \OpenID::attach($log); -if (isset($_POST['start'])) { +if (isset($_POST['openid_url'])) { $_SESSION['openid_url'] = $openid_url; try { -- cgit v1.2.3 From d6d44a3855f93afebd962843cfdfb9952912443e Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 17 Sep 2012 23:48:04 +0200 Subject: show openid of user in forbidden page --- data/templates/forbidden.htm | 14 ++++++++++++-- www/forbidden.php | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'data') diff --git a/data/templates/forbidden.htm b/data/templates/forbidden.htm index 04b8fb6..585c2fe 100644 --- a/data/templates/forbidden.htm +++ b/data/templates/forbidden.htm @@ -5,11 +5,21 @@ acces denied

    Access Denied

    +{% if identity %}

    - We're sorry; but you are not allowed to access this page. + You are logged in with the following OpenID:

    - You may log in if you want. + {{identity}}

    +

    + Unfortunately, your OpenID is not unlocked. + Contact the site administrator to get access. +

    +{% else %} +

    + We're sorry; but you have to log in to access this page. +

    +{% endif %} {% endblock %} diff --git a/www/forbidden.php b/www/forbidden.php index fc166eb..6c44099 100644 --- a/www/forbidden.php +++ b/www/forbidden.php @@ -5,7 +5,10 @@ namespace phorkie; */ render( - 'forbidden' + 'forbidden', + array( + 'identity' => isset($_SESSION['identity']) ? $_SESSION['identity'] : null + ) ); exit(); ?> -- cgit v1.2.3 From 29abc10fb620c14f0ccfcd4ca220e0186274e93c Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 21:20:41 -0400 Subject: ADD: Login button when logged out --- data/templates/base.htm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'data') diff --git a/data/templates/base.htm b/data/templates/base.htm index e503369..7722105 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -32,6 +32,10 @@
  • Logout
  • + {% else %} +
  • + Login +
  • {% endif %} {% if db.adapter %}
  • -- cgit v1.2.3 From e7c60768692aef84b7d35809eb6cb533d04a651b Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 21:21:18 -0400 Subject: FIX: Removed commit message from display --- data/templates/revision-head.htm | 3 --- 1 file changed, 3 deletions(-) (limited to 'data') diff --git a/data/templates/revision-head.htm b/data/templates/revision-head.htm index a5f7e88..9a60b05 100644 --- a/data/templates/revision-head.htm +++ b/data/templates/revision-head.htm @@ -9,9 +9,6 @@

    revision {{repo.hash}}

    -

    - message {{repo.message}} -

  • -- cgit v1.2.3 From 802794fcc585bbb6533c52b6a4c646829bd07b4d Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Mon, 17 Sep 2012 21:47:23 -0400 Subject: FIX: Files without eol --- data/templates/display-sidebar-history.htm | 2 +- data/templates/new.htm | 2 +- data/templates/pager.htm | 2 +- src/phorkie/File.php | 2 +- src/phorkie/GitCommandBinary.php | 2 +- src/phorkie/HtmlHelper.php | 2 +- src/phorkie/Repository/Commit.php | 2 +- src/phorkie/Tool/Manager.php | 2 +- src/phorkie/Tool/Result.php | 2 +- src/phorkie/Tool/Result/Line.php | 2 +- src/phorkie/Tools.php | 2 +- www/js/phorkie.js | 2 +- www/tool.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) (limited to 'data') diff --git a/data/templates/display-sidebar-history.htm b/data/templates/display-sidebar-history.htm index b3ef9df..bf38884 100644 --- a/data/templates/display-sidebar-history.htm +++ b/data/templates/display-sidebar-history.htm @@ -15,4 +15,4 @@ {% else %}

    No commits yet

    {% endfor %} - \ No newline at end of file + diff --git a/data/templates/new.htm b/data/templates/new.htm index 5b75bba..89c2fe0 100644 --- a/data/templates/new.htm +++ b/data/templates/new.htm @@ -37,4 +37,4 @@ $(document).ready(function() { {% endfor %} {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/data/templates/pager.htm b/data/templates/pager.htm index 085a281..9be2b9f 100644 --- a/data/templates/pager.htm +++ b/data/templates/pager.htm @@ -45,4 +45,4 @@ {% endif %}
    -{% endif %} \ No newline at end of file +{% endif %} diff --git a/src/phorkie/File.php b/src/phorkie/File.php index 331f2e5..f378f60 100644 --- a/src/phorkie/File.php +++ b/src/phorkie/File.php @@ -165,4 +165,4 @@ class File } } -?> \ No newline at end of file +?> diff --git a/src/phorkie/GitCommandBinary.php b/src/phorkie/GitCommandBinary.php index 13a31db..a005349 100644 --- a/src/phorkie/GitCommandBinary.php +++ b/src/phorkie/GitCommandBinary.php @@ -12,4 +12,4 @@ class GitCommandBinary extends \VersionControl_Git_Util_Command } } -?> \ No newline at end of file +?> diff --git a/src/phorkie/HtmlHelper.php b/src/phorkie/HtmlHelper.php index af046cf..ea21ab5 100644 --- a/src/phorkie/HtmlHelper.php +++ b/src/phorkie/HtmlHelper.php @@ -25,4 +25,4 @@ class HtmlHelper } } -?> \ No newline at end of file +?> diff --git a/src/phorkie/Repository/Commit.php b/src/phorkie/Repository/Commit.php index 05c988b..62f1d40 100644 --- a/src/phorkie/Repository/Commit.php +++ b/src/phorkie/Repository/Commit.php @@ -70,4 +70,4 @@ class Repository_Commit } } -?> \ No newline at end of file +?> diff --git a/src/phorkie/Tool/Manager.php b/src/phorkie/Tool/Manager.php index 8e18199..ca93b4a 100644 --- a/src/phorkie/Tool/Manager.php +++ b/src/phorkie/Tool/Manager.php @@ -43,4 +43,4 @@ class Tool_Manager } } -?> \ No newline at end of file +?> diff --git a/src/phorkie/Tool/Result.php b/src/phorkie/Tool/Result.php index 22ea273..94dfe5e 100644 --- a/src/phorkie/Tool/Result.php +++ b/src/phorkie/Tool/Result.php @@ -6,4 +6,4 @@ class Tool_Result public $annotations; } -?> \ No newline at end of file +?> diff --git a/src/phorkie/Tool/Result/Line.php b/src/phorkie/Tool/Result/Line.php index a788db6..1fa8bcb 100644 --- a/src/phorkie/Tool/Result/Line.php +++ b/src/phorkie/Tool/Result/Line.php @@ -31,4 +31,4 @@ class Tool_Result_Line } } -?> \ No newline at end of file +?> diff --git a/src/phorkie/Tools.php b/src/phorkie/Tools.php index 843b2df..e4aab63 100644 --- a/src/phorkie/Tools.php +++ b/src/phorkie/Tools.php @@ -62,4 +62,4 @@ class Tools } -?> \ No newline at end of file +?> diff --git a/www/js/phorkie.js b/www/js/phorkie.js index 1171b1a..7078e8f 100644 --- a/www/js/phorkie.js +++ b/www/js/phorkie.js @@ -50,4 +50,4 @@ function toggleAdditional(elem, time) jt.children('i').toggleClass('icon-chevron-down') .toggleClass('icon-chevron-up'); jt.parents('.row-fluid').children('.additional').toggle(time); -} \ No newline at end of file +} diff --git a/www/tool.php b/www/tool.php index d42954c..647d6a7 100644 --- a/www/tool.php +++ b/www/tool.php @@ -30,4 +30,4 @@ render( ) ); -?> \ No newline at end of file +?> -- cgit v1.2.3 From 46e5ed5df53911bd2ae3584ef35f86e5d3094fb3 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 18 Sep 2012 07:29:48 +0200 Subject: Removing access_denied image that was originally from http://wiki.songbirdnest.com/Docs/Songbird_Illustration_Compendium because the songbird people don't let us use the image: > Date: Mon, 17 Sep 2012 16:36:20 -0700 > kristina, an employee of Songbird, replied to license of > "access denied" image from the wiki, a question about Songbird. > Hi cweiske, > Thank you for your inquiry but we would like to keep the right > for all our images be associated with Songbird only. Sorry about that! http://getsatisfaction.com/songbird/topics/license_of_access_denied_image_from_the_wiki --- data/templates/forbidden.htm | 1 - www/images/access_denied.png | Bin 15610 -> 0 bytes 2 files changed, 1 deletion(-) delete mode 100644 www/images/access_denied.png (limited to 'data') diff --git a/data/templates/forbidden.htm b/data/templates/forbidden.htm index 585c2fe..a39bcf7 100644 --- a/data/templates/forbidden.htm +++ b/data/templates/forbidden.htm @@ -3,7 +3,6 @@ {% block content %} -acces denied

    Access Denied

    {% if identity %}

    diff --git a/www/images/access_denied.png b/www/images/access_denied.png deleted file mode 100644 index c13d7b9..0000000 Binary files a/www/images/access_denied.png and /dev/null differ -- cgit v1.2.3 From 3367fca1c9cdeb70c95154f20011b268d4d080a4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 18 Sep 2012 07:41:31 +0200 Subject: rename "secure" config setting to "securityLevel" --- data/config.default.php | 2 +- www/www-security.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'data') diff --git a/data/config.default.php b/data/config.default.php index da16241..0c9ec69 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -13,7 +13,7 @@ $GLOBALS['phorkie']['cfg'] = array( 'index' => 'new'//"new" or "list" ); $GLOBALS['phorkie']['auth'] = array( - 'secure' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = use authentication + 'securityLevel' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = require authentication 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate 'anonymousName' => 'Anonymous', // Email for non-authenticated commits 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits diff --git a/www/www-security.php b/www/www-security.php index 9fae87b..e9fdab7 100644 --- a/www/www-security.php +++ b/www/www-security.php @@ -4,12 +4,12 @@ namespace phorkie; * security levels + login requirement: */ -if (!isset($GLOBALS['phorkie']['auth']['secure'])) { +if (!isset($GLOBALS['phorkie']['auth']['securityLevel'])) { //not set? highest level of security - $GLOBALS['phorkie']['auth']['secure'] = 2; + $GLOBALS['phorkie']['auth']['securityLevel'] = 2; } -if ($GLOBALS['phorkie']['auth']['secure'] == 0) { +if ($GLOBALS['phorkie']['auth']['securityLevel'] == 0) { //everyone may do everything return; } @@ -26,7 +26,7 @@ if (!isset($_SESSION['identity'])) { $logged_in = true; } -if ($secureAtLevel >= $GLOBALS['phorkie']['auth']['secure']) { +if ($secureAtLevel >= $GLOBALS['phorkie']['auth']['securityLevel']) { if ($logged_in) { return; } -- cgit v1.2.3 From 8aa0b9bda25f570e591e554bdbece99d5f6458c8 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 18 Sep 2012 07:46:49 +0200 Subject: rename auth configuration variables to make them more readable --- data/config.default.php | 9 ++++++--- data/config.php.dist | 5 ++++- www/www-security.php | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'data') diff --git a/data/config.default.php b/data/config.default.php index 0c9ec69..a0270b5 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -13,10 +13,13 @@ $GLOBALS['phorkie']['cfg'] = array( 'index' => 'new'//"new" or "list" ); $GLOBALS['phorkie']['auth'] = array( - 'securityLevel' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = require authentication - 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate + // 0 = public, no authentication, 1 = protect adds/edits/deletes, + // 2 = require authentication + 'securityLevel' => 0, + 'listedUsersOnly' => false, + 'users' => array(), // Array of OpenIDs that may login 'anonymousName' => 'Anonymous', // Email for non-authenticated commits - 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits + 'anonymousEmail' => 'anonymous@phorkie', // Email for non-authenticated commits ); $GLOBALS['phorkie']['tools'] = array( '\\phorkie\\Tool_Xmllint' => true, diff --git a/data/config.php.dist b/data/config.php.dist index e90f704..ced993f 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -5,7 +5,10 @@ //$GLOBALS['phorkie']['cfg']['git']['private'] = 'ssh://git@bogo:paste/'; //$GLOBALS['phorkie']['cfg']['elasticsearch'] = 'http://localhost:9200/phorkie/'; //$GLOBALS['phorkie']['cfg']['setupcheck'] = false; -//$GLOBALS['phorkie']['users'] = array( + +//$GLOBALS['phorkie']['auth']['securityLevel'] = 0; +//$GLOBALS['phorkie']['auth']['listedUsersOnly'] = false; +//$GLOBALS['phorkie']['auth']['users'] = array( // 'https://www.google.com/accounts/o8/id?id=ABCDEFGHIJKLMNOPQRSTUVWXYZ', // 'http://anonymous.phorkie.openid' //); diff --git a/www/www-security.php b/www/www-security.php index e9fdab7..ccbdb97 100644 --- a/www/www-security.php +++ b/www/www-security.php @@ -17,8 +17,8 @@ if ($GLOBALS['phorkie']['auth']['securityLevel'] == 0) { $logged_in = false; if (!isset($_SESSION['identity'])) { //not logged in -} else if ($GLOBALS['phorkie']['auth']['userlist']) { - if (in_array($_SESSION['identity'], $GLOBALS['phorkie']['users'])) { +} else if ($GLOBALS['phorkie']['auth']['listedUsersOnly']) { + if (in_array($_SESSION['identity'], $GLOBALS['phorkie']['auth']['users'])) { $logged_in = true; } } else { -- cgit v1.2.3 From a1bceaf02f8f8a3fdbb8042ffcfab4b3a35f14f7 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Tue, 18 Sep 2012 06:51:56 -0400 Subject: CLEAN: Corrected spacing --- data/config.default.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data') diff --git a/data/config.default.php b/data/config.default.php index a0270b5..a087767 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -17,9 +17,9 @@ $GLOBALS['phorkie']['auth'] = array( // 2 = require authentication 'securityLevel' => 0, 'listedUsersOnly' => false, - 'users' => array(), // Array of OpenIDs that may login - 'anonymousName' => 'Anonymous', // Email for non-authenticated commits - 'anonymousEmail' => 'anonymous@phorkie', // Email for non-authenticated commits + 'users' => array(), // Array of OpenIDs that may login + 'anonymousName' => 'Anonymous', // Email for non-authenticated commits + 'anonymousEmail' => 'anonymous@phorkie', // Email for non-authenticated commits ); $GLOBALS['phorkie']['tools'] = array( '\\phorkie\\Tool_Xmllint' => true, -- cgit v1.2.3 From 6dbf5501308792a7ab375a8be5562e8c85a48628 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Tue, 18 Sep 2012 10:15:30 -0400 Subject: CLEAN: reformatted to look consistent --- data/templates/user.htm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/user.htm b/data/templates/user.htm index c8ef387..eb032bd 100644 --- a/data/templates/user.htm +++ b/data/templates/user.htm @@ -6,7 +6,8 @@

    User Profile -

    Please update your git preferences for {{ identity }}

    +

    Please update your git preferences.

    +

    {{ identity }}



    -- cgit v1.2.3 From bd7506015c1976511ccd333417da2aec8e5e18f6 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 18 Sep 2012 18:21:40 +0200 Subject: add vcs-git links to html head, to support autodiscovery apart from DOAP - http://joeyh.name/rfc/rel-vcs/ --- data/templates/display.htm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'data') diff --git a/data/templates/display.htm b/data/templates/display.htm index 5bcb016..799f94d 100644 --- a/data/templates/display.htm +++ b/data/templates/display.htm @@ -5,6 +5,12 @@ {% block meta %} +{% if repo.getCloneURL(true) %} + +{% endif %} +{% if repo.getCloneURL(false) %} + +{% endif %} {% endblock %} {% block content %} -- cgit v1.2.3 From d316adab970b993504ba38736a0f8753ef4bb052 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Tue, 18 Sep 2012 15:25:47 -0400 Subject: Feature: Add Markdown parsing --- ChangeLog | 4 ++++ README.rst | 3 +++ data/config.default.php | 5 +++++ src/phorkie/Renderer/Markdown.php | 27 +++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 src/phorkie/Renderer/Markdown.php (limited to 'data') diff --git a/ChangeLog b/ChangeLog index afefa9a..8557be7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-09-18 Justin J. Novack + + * Add Markdown as a known file-type. + 2012-09-16 Christian Weiske * Implement request #12: DOAP documents for all pastes diff --git a/README.rst b/README.rst index d1c6491..4a157bf 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,9 @@ phorkie stands on the shoulders of giants. $ pear channel-discover zustellzentrum.cweiske.de $ pear install zz/mime_type_plaindetect-alpha + $ pear channel-discover pear.michelf.ca + $ pear install michelf/Markdown + Note that this version of GeSHi is a bit outdated, but it's the fastest way to install it. diff --git a/data/config.default.php b/data/config.default.php index 88c9ae5..3fc48f6 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -57,6 +57,11 @@ $GLOBALS['phorkie']['languages'] = array( 'mime' => 'application/javascript', 'geshi' => 'javascript' ), + 'md' => array( + 'title' => 'Markdown', + 'mime' => 'text/x-markdown', + 'renderer' => '\\phorkie\\Renderer_Markdown' + ), 'pl' => array( 'title' => 'Perl', 'mime' => 'application/x-perl', diff --git a/src/phorkie/Renderer/Markdown.php b/src/phorkie/Renderer/Markdown.php new file mode 100644 index 0000000..628d87f --- /dev/null +++ b/src/phorkie/Renderer/Markdown.php @@ -0,0 +1,27 @@ +getContent()); + + return '
    ' + . $markdown + . '
    '; + } +} + +?> -- cgit v1.2.3 From 29035e26e880fcbc3027d5b6bd283959cb869534 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 19 Sep 2012 00:05:11 +0200 Subject: move login link and user name+email to the right on the navigation bar --- data/templates/base.htm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'data') diff --git a/data/templates/base.htm b/data/templates/base.htm index 7722105..dc06566 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -25,6 +25,15 @@
  • List all
  • + {% if db.adapter %} +
  • + + + +
  • + {% endif %} + + -- cgit v1.2.3