plugin_openid:
* Delegation: Configure what OpenID version the provider is supporting (Version 1 or 2 or both) * A little refactoring done to make code more readable.
This commit is contained in:
parent
6acb2ef440
commit
cb8fe52efe
|
@ -1,3 +1,8 @@
|
|||
Version 1.0 (brockhaus)
|
||||
---------------------------------
|
||||
* Delegation: Configure what OpenID version the provider is supporting (Version 1 or 2 or both)
|
||||
* A little refactoring done to make code more readable.
|
||||
|
||||
Version 0.9 (brockhaus)
|
||||
---------------------------------
|
||||
* If no user has configured his OpenID yet, there will be no OpenID login but a info about that.
|
||||
|
|
|
@ -40,6 +40,12 @@ Wenn Du das aber nicht magst, kannst Du diese Auswahl ausschalten. Dann wird bei
|
|||
@define('PLUGIN_OPENID_XRDS_LOC', 'OpenID XRDS Location');
|
||||
@define('PLUGIN_OPENID_XRDS_LOC_DESC', 'URL des XRDS Dokumentes (wird meist nicht benötigt)');
|
||||
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED', 'OpenID Version');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_DESC', 'Die OpenID Version, die Dein Provider unterstützt. Normaler Weise ist "Beide" die richtige Einstellung, aber wenn Du weißt, dass Dein Provider nur Version 1 oder nur Version 2 unterstützt, dann kannst Du das hier einstellen..');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_V1', 'Nur OpenID Version 1');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_V2', 'Nur OpenID Version 2');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_BOTH', 'Beide OpenID Versionen');
|
||||
|
||||
@define('PLUGIN_OPENID_LOGIN_INPUT', 'Melde Dich mit Deiner OpenID an.');
|
||||
|
||||
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Deine OpenID wurde erneuert.');
|
||||
|
|
|
@ -40,6 +40,12 @@ Wenn Du das aber nicht magst, kannst Du diese Auswahl ausschalten. Dann wird bei
|
|||
@define('PLUGIN_OPENID_XRDS_LOC', 'OpenID XRDS Location');
|
||||
@define('PLUGIN_OPENID_XRDS_LOC_DESC', 'URL des XRDS Dokumentes (wird meist nicht benötigt)');
|
||||
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED', 'OpenID Version');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_DESC', 'Die OpenID Version, die Dein Provider unterstützt. Normaler Weise ist "Beide" die richtige Einstellung, aber wenn Du weißt, dass Dein Provider nur Version 1 oder nur Version 2 unterstützt, dann kannst Du das hier einstellen..');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_V1', 'Nur OpenID Version 1');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_V2', 'Nur OpenID Version 2');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_BOTH', 'Beide OpenID Versionen');
|
||||
|
||||
@define('PLUGIN_OPENID_LOGIN_INPUT', 'Melde Dich mit Deiner OpenID an.');
|
||||
|
||||
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Deine OpenID wurde erneuert.');
|
||||
|
|
|
@ -40,6 +40,12 @@ But if you don\'t like that you can switch this off and there will be a normal O
|
|||
@define('PLUGIN_OPENID_XRDS_LOC', 'OpenID XRDS Location');
|
||||
@define('PLUGIN_OPENID_XRDS_LOC_DESC', 'URL for XRDS Document Location (not needed normaly)');
|
||||
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED', 'OpenID Version');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_DESC', 'The version your OpenID provider is supporting. Normaly "both" is okay, but if you know your provider does support only version 1 or only version 2 you can configure it here.');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_V1', 'OpenID Version 1 only');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_V2', 'OpenID Version 2 only');
|
||||
@define('PLUGIN_OPENID_VERSION_SUPPORTED_BOTH', 'Both OpenID Versions');
|
||||
|
||||
@define('PLUGIN_OPENID_LOGIN_INPUT', 'Logon using your OpenID.');
|
||||
|
||||
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Your OpenID has been updated');
|
||||
|
|
|
@ -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.9');
|
||||
$propbag->add('version', '1.0');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '1.2',
|
||||
'smarty' => '2.6.7',
|
||||
|
@ -34,7 +34,8 @@ class serendipity_event_openid extends serendipity_event
|
|||
'delegation_desc',
|
||||
'server',
|
||||
'delegate',
|
||||
'xrds_location'
|
||||
'xrds_location',
|
||||
'openid_version'
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -73,6 +74,18 @@ class serendipity_event_openid extends serendipity_event
|
|||
$propbag->add('description', PLUGIN_OPENID_XRDS_LOC_DESC);
|
||||
$propbag->add('default', '');
|
||||
break;
|
||||
case 'openid_version':
|
||||
$id_services = array(
|
||||
'both' => PLUGIN_OPENID_VERSION_SUPPORTED_BOTH,
|
||||
'v2' => PLUGIN_OPENID_VERSION_SUPPORTED_V2,
|
||||
'v1' => PLUGIN_OPENID_VERSION_SUPPORTED_V1,
|
||||
);
|
||||
$propbag->add('type', 'select');
|
||||
$propbag->add('name', PLUGIN_OPENID_VERSION_SUPPORTED);
|
||||
$propbag->add('description', PLUGIN_OPENID_VERSION_SUPPORTED_DESC);
|
||||
$propbag->add('select_values', $id_services);
|
||||
$propbag->add('default', 'both');
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -127,20 +140,7 @@ class serendipity_event_openid extends serendipity_event
|
|||
}
|
||||
break;
|
||||
case 'frontend_header':
|
||||
$server = $this->get_config('server');
|
||||
$openidurl = $this->get_config('delegate');
|
||||
$xrdsloc = $this->get_config('xrds_location');
|
||||
if (! empty($server) && (! empty($openidurl) || ! empty($xrdsloc))) {
|
||||
/* Make sure linefeeds exist otherwise OpenID does not always work correctly */
|
||||
echo "\n";
|
||||
echo '<link rel="openid.server" href="'.$server.'" /> '."\n";
|
||||
if (! empty($openidurl)) {
|
||||
echo '<link rel="openid.delegate" href="'.$openidurl.'" /> '."\n";
|
||||
}
|
||||
if (! empty($xrdsloc)) {
|
||||
echo '<meta http-equiv="X-XRDS-Location" content="'.$xrdsloc.'" /> '."\n";
|
||||
}
|
||||
}
|
||||
$this->print_header();
|
||||
break;
|
||||
|
||||
case 'backend_login_page':
|
||||
|
@ -152,6 +152,22 @@ class serendipity_event_openid extends serendipity_event
|
|||
break;
|
||||
|
||||
case 'backend_login':
|
||||
return $this->do_login($eventData);
|
||||
|
||||
case 'backend_sidebar_entries_event_display_profiles':
|
||||
$this->print_sidebar();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function do_login(&$eventData) {
|
||||
global $serendipity;
|
||||
|
||||
$inOpenIdChange = !empty($serendipity['POST']['openidflag']) && ($serendipity['POST']['openidflag']==3);
|
||||
if ($eventData && !$inOpenIdChange) { // Eventdata holds "isAuthentificated". So if she is, let her in.
|
||||
return true;
|
||||
|
@ -191,8 +207,41 @@ class serendipity_event_openid extends serendipity_event
|
|||
$eventData = serendipity_common_openid::redir_openidserver($openidurl, $this->get_consumertest_path(), 1);
|
||||
}
|
||||
return $eventData;
|
||||
}
|
||||
|
||||
function print_header() {
|
||||
$server = $this->get_config('server');
|
||||
$openidurl = $this->get_config('delegate');
|
||||
$xrdsloc = $this->get_config('xrds_location');
|
||||
if (! empty($server) && (! empty($openidurl) || ! empty($xrdsloc))) {
|
||||
$supported_version = $this->get_config('openid_version', 'both');
|
||||
if ('v1'==$supported_version) {
|
||||
$rel_oserver = "openid.server";
|
||||
$rel_odelegate = "openid.delegate";
|
||||
}
|
||||
elseif ('v2'==$supported_version) {
|
||||
$rel_oserver = "openid2.provider";
|
||||
$rel_odelegate = "openid2.local_id";
|
||||
}
|
||||
else {
|
||||
$rel_oserver = "openid.server openid2.provider";
|
||||
$rel_odelegate = "openid.delegate openid2.local_id";
|
||||
}
|
||||
/* Make sure linefeeds exist otherwise OpenID does not always work correctly */
|
||||
echo "\n";
|
||||
echo '<link rel="' . $rel_oserver .'" href="'.$server.'" /> '."\n";
|
||||
if (! empty($openidurl)) {
|
||||
echo '<link rel="' . $rel_odelegate .'" href="'.$openidurl.'" /> '."\n";
|
||||
}
|
||||
if (! empty($xrdsloc)) {
|
||||
echo '<meta http-equiv="X-XRDS-Location" content="'.$xrdsloc.'" /> '."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function print_sidebar() {
|
||||
global $serendipity;
|
||||
|
||||
case 'backend_sidebar_entries_event_display_profiles':
|
||||
if (($_SESSION['serendipityAuthedUser'] == true)) {
|
||||
if (! empty($serendipity['GET']['openidflag']) && ($serendipity['GET']['openidflag']==3)) {
|
||||
if ($checkRet = serendipity_common_openid::authenticate_openid($_GET, $this->get_consumertest_path(), true)) {
|
||||
|
@ -237,13 +286,6 @@ class serendipity_event_openid extends serendipity_event
|
|||
echo '</form>';
|
||||
|
||||
echo '</div><br /><hr />';
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function get_consumertest_path() {
|
||||
|
|
Loading…
Reference in a new issue