plugin_browserid: A first start.
This commit is contained in:
parent
eafd30cc84
commit
5a1403cd71
BIN
serendipity_event_browserid/browserid_signin.png
Normal file
BIN
serendipity_event_browserid/browserid_signin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
9
serendipity_event_browserid/lang_en.inc.php
Normal file
9
serendipity_event_browserid/lang_en.inc.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
@define('PLUGIN_BROWSERID_NAME', 'BrowserID Authentication');
|
||||
@define('PLUGIN_BROWSERID_DESC', 'Allows authors to authenticate using an BrowserID.');
|
||||
|
||||
@define('PLUGIN_BROWSERID_DESCRIPTION',
|
||||
'<h3>Using BrwoserID to log into your blog</h3>' .
|
||||
'<p>Blah!</p>'
|
||||
);
|
|
@ -0,0 +1,6 @@
|
|||
$(function() {
|
||||
$('#browserid').click(function() {
|
||||
navigator.id.get(gotAssertion);
|
||||
return false;
|
||||
});
|
||||
});
|
115
serendipity_event_browserid/serendipity_event_browserid.php
Normal file
115
serendipity_event_browserid/serendipity_event_browserid.php
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?php # $Id$
|
||||
|
||||
// Probe for a language include with constants. Still include defines later on, if some constants were missing
|
||||
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
|
||||
if (file_exists($probelang)) {
|
||||
include $probelang;
|
||||
}
|
||||
include_once dirname(__FILE__) . '/lang_en.inc.php';
|
||||
|
||||
class serendipity_event_browserid extends serendipity_event
|
||||
{
|
||||
function introspect(&$propbag)
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
$propbag->add('name', PLUGIN_BROWSERID_NAME);
|
||||
$propbag->add('description', PLUGIN_BROWSERID_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Grischa Brockhaus');
|
||||
$propbag->add('version', '0.1');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '1.6',
|
||||
'smarty' => '2.6.7',
|
||||
'php' => '5.1.3'
|
||||
));
|
||||
$propbag->add('groups', array('BACKEND_USERMANAGEMENT'));
|
||||
$propbag->add('event_hooks', array(
|
||||
'backend_login' => true,
|
||||
'backend_login_page' => true,
|
||||
'external_plugin' => true,
|
||||
));
|
||||
|
||||
$propbag->add('configuration', array(
|
||||
'plugin_desc',
|
||||
));
|
||||
}
|
||||
|
||||
function introspect_config_item($name, &$propbag)
|
||||
{
|
||||
switch($name) {
|
||||
case 'plugin_desc':
|
||||
$propbag->add('type', 'content');
|
||||
$propbag->add('default', PLUGIN_BROWSERID_DESCRIPTION);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function generate_content(&$title) {
|
||||
$title = PLUGIN_OPENID_NAME;
|
||||
}
|
||||
|
||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
||||
global $serendipity;
|
||||
static $login_url = null;
|
||||
|
||||
if ($login_url === null) {
|
||||
$login_url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/loginbox';
|
||||
}
|
||||
|
||||
$hooks = &$bag->get('event_hooks');
|
||||
|
||||
if (isset($hooks[$event])) {
|
||||
switch($event) {
|
||||
case 'external_plugin':
|
||||
if ($eventData=="serendipity_event_browserid.js") {
|
||||
header('Content-Type: text/javascript');
|
||||
echo file_get_contents(dirname(__FILE__). '/serendipity_event_browserid.js');
|
||||
}
|
||||
else if ($eventData=="browserid_signin.png") {
|
||||
header('Content-Type: image/png');
|
||||
echo file_get_contents(dirname(__FILE__). '/browserid_signin.png');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'backend_login_page':
|
||||
$this->print_loginpage($eventData);
|
||||
break;
|
||||
|
||||
case 'backend_login':
|
||||
if ($eventData) {
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function print_loginpage(&$eventData) {
|
||||
global $serendipity;
|
||||
|
||||
$hidden = array('action'=>'admin');
|
||||
$bid_title = "Sign-in with BrowserID";
|
||||
$local_js = $serendipity['baseURL'] . 'index.php?/plugin/serendipity_event_browserid.js';
|
||||
$local_signin_img = $serendipity['baseURL'] . 'index.php?/plugin/browserid_signin.png';
|
||||
|
||||
$eventData['header'] .=
|
||||
"\n<!-- browserid start -->\n" .
|
||||
'<script src="https://browserid.org/include.js" type="text/javascript"></script>' . "\n" .
|
||||
'<script src="' . $local_js . '" type="text/javascript"></script>' . "\n" .
|
||||
'<div align="center"><p>'.
|
||||
'<a href="#" id="browserid" title="' . $bid_title . '"><img src="' . $local_signin_img . '" alt="' . $bid_title . '" title="' . $bid_title . '"></a>'.
|
||||
'</p></div>' .
|
||||
"\n<!-- browserid end -->\n";
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
|
@ -13,7 +13,7 @@ class serendipity_event_openid extends serendipity_event
|
|||
$propbag->add('description', PLUGIN_OPENID_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Grischa Brockhaus, Rob Richards');
|
||||
$propbag->add('version', '0.6');
|
||||
$propbag->add('version', '0.5');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '1.2',
|
||||
'smarty' => '2.6.7',
|
||||
|
@ -139,6 +139,7 @@ class serendipity_event_openid extends serendipity_event
|
|||
}
|
||||
} else if (! empty($serendipity['GET']['openidflag']) && ($serendipity['GET']['openidflag']==1)) {
|
||||
$eventData = serendipity_common_openid::authenticate_openid($_GET, $this->get_consumertest_path());
|
||||
print_r($eventData);
|
||||
} else if (! empty($serendipity['POST']['openid_url']) && ! empty($serendipity['POST']['action'])) {
|
||||
$eventData = serendipity_common_openid::redir_openidserver($serendipity['POST']['openid_url'], $this->get_consumertest_path(), 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue