plugin_openid:
* Was not able to change users OpenID url, if logged in with another external login (like BrowserID) * Added Google and Yahoo as shortcuts. They provide OpenID with a generic URL.
This commit is contained in:
parent
268cd4b3cd
commit
3fcd694f8b
|
@ -1,3 +1,8 @@
|
|||
Version 0.7 (brockhaus)
|
||||
---------------------------------
|
||||
* Was not able to change users OpenID url, if logged in with another external login (like BrowserID)
|
||||
* Added Google and Yahoo as shortcuts. They provide OpenID with a generic URL.
|
||||
|
||||
Version 0.6 (brockhaus)
|
||||
---------------------------------
|
||||
* Patched OpenID library to do an autofallback, if /dev/urandom is not accessible instead of failing completely.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
@define('PLUGIN_OPENID_NAME', 'OpenID Authentifizierung');
|
||||
@define('PLUGIN_OPENID_DESC', 'Ermöglicht es Autoren des Blogs, sich mit ihrer OpenID einzuloggen.');
|
||||
@define('PLUGIN_OPENID_DESC', 'Ermöglicht es Autoren des Blogs, sich mit ihrer OpenID (oder Google/Yahoo Account) einzuloggen.');
|
||||
|
||||
@define('PLUGIN_OPENID_EXISTS', 'Du bist bereits mit OpenID registriert.');
|
||||
@define('PLUGIN_OPENID_WRONG_ACTIVATION', 'Ungültige Aktivierungs URL!');
|
||||
|
@ -36,3 +36,8 @@
|
|||
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Deine OpenID wurde erneuert.');
|
||||
@define('PLUGIN_OPENID_UPDATE_FAIL', 'Es trat ein Fehler beim Update Deiner OpenID auf.');
|
||||
@define('PLUGIN_OPENID_INVALID_RESPONSE', 'Ungültige OpenID eingegeben');
|
||||
|
||||
@define('PLUGIN_OPENID_LOGIN_WITH_GOOGLE', 'Mit Deinem Google Account einloggen');
|
||||
@define('PLUGIN_OPENID_SET_GOOGLE_OID', 'Deinen Google Account als OpenID setzen');
|
||||
@define('PLUGIN_OPENID_LOGIN_WITH_YAHOO', 'Mit Deinem Yahoo Account einloggen');
|
||||
@define('PLUGIN_OPENID_SET_YAHOO_OID', 'Deinen Yahoo Account als OpenID setzen');
|
||||
|
|
|
@ -126,41 +126,7 @@ class serendipity_common_openid {
|
|||
$success .= " Your fullname is '".escape($sreg['fullname']).
|
||||
"'.";
|
||||
}
|
||||
/*
|
||||
$pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
|
||||
|
||||
if ($pape_resp) {
|
||||
if ($pape_resp->auth_policies) {
|
||||
$success .= "<p>The following PAPE policies affected the authentication:</p><ul>";
|
||||
|
||||
foreach ($pape_resp->auth_policies as $uri) {
|
||||
$escaped_uri = escape($uri);
|
||||
$success .= "<li><tt>$escaped_uri</tt></li>";
|
||||
}
|
||||
|
||||
$success .= "</ul>";
|
||||
} else {
|
||||
$success .= "<p>No PAPE policies affected the authentication.</p>";
|
||||
}
|
||||
|
||||
if ($pape_resp->auth_age) {
|
||||
$age = ($pape_resp->auth_age);
|
||||
$success .= "<p>The authentication age returned by the " .
|
||||
"server is: <tt>".$age."</tt></p>";
|
||||
}
|
||||
|
||||
if ($pape_resp->nist_auth_level) {
|
||||
$auth_level = escape($pape_resp->nist_auth_level);
|
||||
$success .= "<p>The NIST auth level returned by the " .
|
||||
"server is: <tt>".$auth_level."</tt></p>";
|
||||
}
|
||||
|
||||
} else {
|
||||
$success .= "<p>No PAPE response was sent by the provider.</p>";
|
||||
}
|
||||
*/
|
||||
}
|
||||
//print "Message: $success";
|
||||
|
||||
if (! empty($openid)) {
|
||||
if ($returnData) {
|
||||
|
@ -238,18 +204,33 @@ class serendipity_common_openid {
|
|||
function loginform($url, $hidden = array(), $instructions = '') {
|
||||
global $serendipity;
|
||||
|
||||
$imgpath = $serendipity['baseURL'] . 'index.php?/plugin/openid.png';
|
||||
$imgopenid = $serendipity['baseURL'] . 'index.php?/plugin/openid.png';
|
||||
$imggoogle = $serendipity['baseURL'] . 'index.php?/plugin/oid_google.png';
|
||||
$imgyahoo = $serendipity['baseURL'] . 'index.php?/plugin/oid_yahoo.png';
|
||||
$form = '';
|
||||
if (! empty($instructions)) {
|
||||
$form = $instructions . '<br /><br />';
|
||||
}
|
||||
$form .= '<form name="openid" id="openid" method="post" action="' . $url . '">'.
|
||||
"\n ".' <input type="hidden" name="serendipity[openidflag]" value="1" />'."\n ";
|
||||
|
||||
// We need two forms in order to allow ENTER in the input line
|
||||
$form .= '<form name="openid" id="openid" method="post" action="' . $url . '">';
|
||||
$form .='<input type="hidden" name="serendipity[openidflag]" value="1" />';
|
||||
foreach($hidden AS $key => $val) {
|
||||
$form .= '<input type="hidden" name="serendipity[' . $key . ']" value="' . htmlspecialchars($val) . '" />' . "\n";
|
||||
$form .= '<input type="hidden" name="serendipity[' . $key . ']" value="' . htmlspecialchars($val) . '" />';
|
||||
}
|
||||
$form .= '<img src="' . $imgpath . '" alt="OpenID"> <input type="text" size="40" name="serendipity[openid_url]" value="" placeholder="' . PLUGIN_OPENID_LOGIN_INPUT . '"/>'."\n".
|
||||
'<input type="submit" name="openIDLogin" value="Login" /></form>';
|
||||
$form .= '<img src="' . $imgopenid . '" alt="OpenID"> <input type="text" size="40" name="serendipity[openid_url]" value="" placeholder="' . PLUGIN_OPENID_LOGIN_INPUT . '"/>'."\n".
|
||||
'<input type="submit" name="openIDLogin" value="Login" />';
|
||||
$form .= '</form>';
|
||||
|
||||
$form .= '<form name="openid" id="openid" method="post" action="' . $url . '">';
|
||||
$form .='<input type="hidden" name="serendipity[openidflag]" value="1" />';
|
||||
foreach($hidden AS $key => $val) {
|
||||
$form .= '<input type="hidden" name="serendipity[' . $key . ']" value="' . htmlspecialchars($val) . '" />';
|
||||
}
|
||||
$form .= '<input name="openIDLoginGoogle" type="image" src="' . $imggoogle . '" alt="' . PLUGIN_OPENID_LOGIN_WITH_GOOGLE . '" title="' . PLUGIN_OPENID_LOGIN_WITH_GOOGLE .'"/> ';
|
||||
$form .= '<input name="openIDLoginYahoo" type="image" src="' . $imgyahoo . '" alt="' . PLUGIN_OPENID_LOGIN_WITH_YAHOO . '" title="' . PLUGIN_OPENID_LOGIN_WITH_YAHOO .'"/> ';
|
||||
$form .= '</form>';
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
|
BIN
serendipity_event_openid/img/google.png
Normal file
BIN
serendipity_event_openid/img/google.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
serendipity_event_openid/img/google_small.png
Normal file
BIN
serendipity_event_openid/img/google_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 713 B |
BIN
serendipity_event_openid/img/yahoo.png
Normal file
BIN
serendipity_event_openid/img/yahoo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
serendipity_event_openid/img/yahoo_small.png
Normal file
BIN
serendipity_event_openid/img/yahoo_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
@define('PLUGIN_OPENID_NAME', 'OpenID Authentifizierung');
|
||||
@define('PLUGIN_OPENID_DESC', 'Ermöglicht es Autoren des Blogs, sich mit ihrer OpenID einzuloggen.');
|
||||
@define('PLUGIN_OPENID_DESC', 'Ermöglicht es Autoren des Blogs, sich mit ihrer OpenID (oder Google/Yahoo Account) einzuloggen.');
|
||||
|
||||
@define('PLUGIN_OPENID_EXISTS', 'Du bist bereits mit OpenID registriert.');
|
||||
@define('PLUGIN_OPENID_WRONG_ACTIVATION', 'Ungültige Aktivierungs URL!');
|
||||
|
@ -36,3 +36,8 @@
|
|||
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Deine OpenID wurde erneuert.');
|
||||
@define('PLUGIN_OPENID_UPDATE_FAIL', 'Es trat ein Fehler beim Update Deiner OpenID auf.');
|
||||
@define('PLUGIN_OPENID_INVALID_RESPONSE', 'Ungültige OpenID eingegeben');
|
||||
|
||||
@define('PLUGIN_OPENID_LOGIN_WITH_GOOGLE', 'Mit Deinem Google Account einloggen');
|
||||
@define('PLUGIN_OPENID_SET_GOOGLE_OID', 'Deinen Google Account als OpenID setzen');
|
||||
@define('PLUGIN_OPENID_LOGIN_WITH_YAHOO', 'Mit Deinem Yahoo Account einloggen');
|
||||
@define('PLUGIN_OPENID_SET_YAHOO_OID', 'Deinen Yahoo Account als OpenID setzen');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
@define('PLUGIN_OPENID_NAME', 'OpenID Authentication');
|
||||
@define('PLUGIN_OPENID_DESC', 'Allows authors to authenticate using an OpenID.');
|
||||
@define('PLUGIN_OPENID_DESC', 'Allows authors to authenticate using an OpenID, their Google or Yahoo account.');
|
||||
|
||||
@define('PLUGIN_OPENID_EXISTS', 'You have already registered with this OpenID.');
|
||||
@define('PLUGIN_OPENID_WRONG_ACTIVATION', 'Invalid activation URL!');
|
||||
|
@ -36,3 +36,8 @@
|
|||
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Your OpenID has been updated');
|
||||
@define('PLUGIN_OPENID_UPDATE_FAIL', 'An Error occurred updating your OpenID');
|
||||
@define('PLUGIN_OPENID_INVALID_RESPONSE', 'Invalid OpenID Entered');
|
||||
|
||||
@define('PLUGIN_OPENID_LOGIN_WITH_GOOGLE', 'Login with your Google account');
|
||||
@define('PLUGIN_OPENID_SET_GOOGLE_OID', 'Set your Google account as OpenID');
|
||||
@define('PLUGIN_OPENID_LOGIN_WITH_YAHOO', 'Login with your Yahoo account');
|
||||
@define('PLUGIN_OPENID_SET_YAHOO_OID', 'Set your Yahoo account as OpenID');
|
||||
|
|
|
@ -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.7');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '1.2',
|
||||
'smarty' => '2.6.7',
|
||||
|
@ -92,7 +92,23 @@ class serendipity_event_openid extends serendipity_event
|
|||
case 'external_plugin' :
|
||||
if ($eventData=="openid.png") {
|
||||
header('Content-Type: image/png');
|
||||
echo file_get_contents(dirname(__FILE__). '/openid.png');
|
||||
echo file_get_contents(dirname(__FILE__). '/img/openid.png');
|
||||
}
|
||||
elseif ($eventData=="oid_google.png") {
|
||||
header('Content-Type: image/png');
|
||||
echo file_get_contents(dirname(__FILE__). '/img/google.png');
|
||||
}
|
||||
elseif ($eventData=="oids_google.png") {
|
||||
header('Content-Type: image/png');
|
||||
echo file_get_contents(dirname(__FILE__). '/img/google_small.png');
|
||||
}
|
||||
elseif ($eventData=="oid_yahoo.png") {
|
||||
header('Content-Type: image/png');
|
||||
echo file_get_contents(dirname(__FILE__). '/img/yahoo.png');
|
||||
}
|
||||
elseif ($eventData=="oids_yahoo.png") {
|
||||
header('Content-Type: image/png');
|
||||
echo file_get_contents(dirname(__FILE__). '/img/yahoo_small.png');
|
||||
}
|
||||
break;
|
||||
case 'frontend_header':
|
||||
|
@ -120,30 +136,43 @@ class serendipity_event_openid extends serendipity_event
|
|||
break;
|
||||
|
||||
case 'backend_login':
|
||||
if ($eventData) {
|
||||
$inOpenIdChange = !empty($serendipity['POST']['openidflag']) && ($serendipity['POST']['openidflag']==3);
|
||||
if ($eventData && !$inOpenIdChange) { // Eventdata holds "isAuthentificated". So if she is, let her in.
|
||||
return true;
|
||||
}
|
||||
|
||||
$openidurl = NULL;
|
||||
if (!empty($serendipity['POST']['openid_url'])) {
|
||||
$openidurl = $serendipity['POST']['openid_url'];
|
||||
}
|
||||
elseif (isset($_POST['openIDLoginGoogle_x']) || isset($_POST['openIDLoginGoogle_y'])) { // If the Google Button was pressed
|
||||
$openidurl = "https://www.google.com/accounts/o8/id";
|
||||
}
|
||||
elseif (isset($_POST['openIDLoginYahoo_x']) || isset($_POST['openIDLoginYahoo_y'])) { // If the Google Button was pressed
|
||||
$openidurl = "https://yahoo.com";
|
||||
}
|
||||
|
||||
if ($_SESSION['serendipityAuthedUser'] == true) {
|
||||
$eventData = serendipity_common_openid::reauth_openid();
|
||||
if (! empty($serendipity['POST']['openid_url']) && ! empty($serendipity['POST']['openidflag'])) {
|
||||
if (!empty($openidurl) && !empty($serendipity['POST']['openidflag'])) {
|
||||
/* Check that openid isn't already associated with another login */
|
||||
$tmpRet = serendipity_common_openid::redir_openidserver($serendipity['POST']['openid_url'], $this->get_consumertest_path(), 3);
|
||||
$tmpRet = serendipity_common_openid::redir_openidserver($openidurl, $this->get_consumertest_path(), 3);
|
||||
|
||||
/* If updating an OpenID it is not a real login attempt */
|
||||
if (($tmpRet === false) && (($serendipity['GET']['openidflag']==3) || ($serendipity['POST']['openidflag']==3))) {
|
||||
return;
|
||||
}
|
||||
$eventData = $tmpRet;
|
||||
} else {
|
||||
} elseif (!empty($serendipity['POST']['openidflag'])) {
|
||||
$eventData = serendipity_common_openid::reauth_openid();
|
||||
}
|
||||
} else if (! empty($serendipity['GET']['openidflag']) && ($serendipity['GET']['openidflag']==1)) {
|
||||
$eventData = serendipity_common_openid::authenticate_openid($_GET, $this->get_consumertest_path());
|
||||
} 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);
|
||||
} else if (! empty($openidurl) && ! empty($serendipity['POST']['action'])) {
|
||||
$eventData = serendipity_common_openid::redir_openidserver($openidurl, $this->get_consumertest_path(), 1);
|
||||
}
|
||||
return;
|
||||
|
||||
return $eventData;
|
||||
|
||||
case 'backend_sidebar_entries_event_display_profiles':
|
||||
if (($_SESSION['serendipityAuthedUser'] == true)) {
|
||||
if (! empty($serendipity['GET']['openidflag']) && ($serendipity['GET']['openidflag']==3)) {
|
||||
|
@ -156,20 +185,37 @@ class serendipity_event_openid extends serendipity_event
|
|||
} else {
|
||||
echo '<strong>' . htmlspecialchars(PLUGIN_OPENID_INVALID_RESPONSE) . '</strong><br /><br />';
|
||||
}
|
||||
// Job done.
|
||||
unset($serendipity['GET']['openidflag']);
|
||||
} elseif (! empty($serendipity['POST']['openidflag']) && ($serendipity['POST']['openidflag']==3)) {
|
||||
echo '<strong>' . htmlspecialchars(PLUGIN_OPENID_INVALID_RESPONSE) . '</strong><br /><br />';
|
||||
}
|
||||
}
|
||||
$imgpath = $serendipity['baseURL'] . 'index.php?/plugin/openid.png';
|
||||
$imgopenid = $serendipity['baseURL'] . 'index.php?/plugin/openid.png';
|
||||
$imggoogle = $serendipity['baseURL'] . 'index.php?/plugin/oids_google.png';
|
||||
$imgyahoo = $serendipity['baseURL'] . 'index.php?/plugin/oids_yahoo.png';
|
||||
|
||||
echo '<div>';
|
||||
echo '<strong>' . htmlspecialchars(PLUGIN_EVENT_OPENID_SELECT) . '</strong><br /><br />';
|
||||
|
||||
// To allow ENTER in the input line we have to create two forms:
|
||||
|
||||
echo '<form action="?" method="post">';
|
||||
echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />';
|
||||
echo '<input type="hidden" name="serendipity[adminAction]" value="profiles" />';
|
||||
echo '<input type="hidden" name="serendipity[openidflag]" value="3" />';
|
||||
echo '<div>';
|
||||
echo '<strong>' . htmlspecialchars(PLUGIN_EVENT_OPENID_SELECT) . '</strong><br /><br />';
|
||||
echo '<img src="' . $imgpath . '" alt="OpenID URL"> <input type="text" size="50" name="serendipity[openid_url]" value="'. serendipity_common_openid::getOpenID($serendipity['authorid']) .'" />';
|
||||
echo ' <input type="submit" name="submit" value="' . EDIT . '" />';
|
||||
echo '</div><br /><hr /></form>';
|
||||
echo '<img src="' . $imgopenid . '" alt="OpenID URL"> <input type="text" size="50" name="serendipity[openid_url]" value="'. serendipity_common_openid::getOpenID($serendipity['authorid']) .'" />';
|
||||
echo ' <input type="submit" name="submit" value="' . EDIT . '" placeholder="' . PLUGIN_OPENID_LOGIN_INPUT . '"/>';
|
||||
echo '</form>';
|
||||
echo '<form action="?" method="post">';
|
||||
echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />';
|
||||
echo '<input type="hidden" name="serendipity[adminAction]" value="profiles" />';
|
||||
echo '<input type="hidden" name="serendipity[openidflag]" value="3" />';
|
||||
echo '<input name="openIDLoginGoogle" type="image" src="' . $imggoogle . '" alt="' . PLUGIN_OPENID_SET_GOOGLE_OID .'" title="'. PLUGIN_OPENID_SET_GOOGLE_OID .'"/> ';
|
||||
echo '<input name="openIDLoginYahoo" type="image" src="' . $imgyahoo . '" alt="' . PLUGIN_OPENID_SET_YAHOO_OID .'" title="'. PLUGIN_OPENID_SET_YAHOO_OID .'"/> ';
|
||||
echo '</form>';
|
||||
|
||||
echo '</div><br /><hr />';
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue