[OpenID] Added support for GS's Internal Session Handler
This commit is contained in:
@@ -93,7 +93,7 @@ class OpenidsettingsAction extends SettingsAction
|
||||
'action' =>
|
||||
common_local_url('openidsettings')]);
|
||||
$this->elementStart('fieldset', ['id' => 'settings_openid_add']);
|
||||
|
||||
|
||||
// TRANS: Fieldset legend.
|
||||
$this->element('legend', null, _m('LEGEND', 'Add OpenID'));
|
||||
$this->hidden('token', common_session_token());
|
||||
@@ -127,7 +127,7 @@ class OpenidsettingsAction extends SettingsAction
|
||||
if ($cnt > 0) {
|
||||
// TRANS: Header on OpenID settings page.
|
||||
$this->element('h2', null, _m('HEADER', 'OpenID Actions'));
|
||||
|
||||
|
||||
if ($cnt == 1 && !$this->scoped->hasPassword()) {
|
||||
$this->element('p', 'form_guide',
|
||||
// TRANS: Form guide.
|
||||
@@ -218,7 +218,7 @@ class OpenidsettingsAction extends SettingsAction
|
||||
// TRANS: Button text to remove an OpenID trustroot.
|
||||
$this->submit('settings_openid_trustroots_action-submit', _m('BUTTON', 'Remove'), 'submit', 'remove_trustroots');
|
||||
$this->elementEnd('fieldset');
|
||||
|
||||
|
||||
$prefs = User_openid_prefs::getKV('user_id', $this->scoped->getID());
|
||||
|
||||
$this->elementStart('fieldset');
|
||||
@@ -247,9 +247,8 @@ class OpenidsettingsAction extends SettingsAction
|
||||
// TRANS: Form validation error if no OpenID providers can be added.
|
||||
throw new ServerException(_m('Cannot add new providers.'));
|
||||
} else {
|
||||
common_ensure_session();
|
||||
$_SESSION['openid_synch'] = $this->boolean('openid-synch');
|
||||
|
||||
|
||||
$result = oid_authenticate($this->trimmed('openid_url'), 'finishaddopenid');
|
||||
if (is_string($result)) { // error message
|
||||
unset($_SESSION['openid-synch']);
|
||||
@@ -335,7 +334,7 @@ class OpenidsettingsAction extends SettingsAction
|
||||
if (!$oid instanceof User_openid) {
|
||||
throw new ClientException(_m('No such OpenID.'));
|
||||
}
|
||||
|
||||
|
||||
$result = oid_authenticate($this->trimmed('openid_url'), 'finishsynchopenid');
|
||||
if (is_string($result)) { // error message
|
||||
throw new ServerException($result);
|
||||
|
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-06-10 15:40+0100\n"
|
||||
"POT-Creation-Date: 2019-06-10 16:49+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -205,40 +205,40 @@ msgid "Cannot add new providers."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Unexpected form validation error.
|
||||
#: actions/openidsettings.php:271
|
||||
#: actions/openidsettings.php:270
|
||||
msgid "No known action for POST."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Form validation error when trying to remove a non-existing trustroot.
|
||||
#: actions/openidsettings.php:293
|
||||
#: actions/openidsettings.php:292
|
||||
msgid "No such OpenID trustroot."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Success message after removing trustroots.
|
||||
#: actions/openidsettings.php:298
|
||||
#: actions/openidsettings.php:297
|
||||
msgid "Trustroots removed."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Form validation error for a non-existing OpenID.
|
||||
#: actions/openidsettings.php:315 actions/openidsettings.php:336
|
||||
#: actions/openidsettings.php:314 actions/openidsettings.php:335
|
||||
msgid "No such OpenID."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Form validation error if OpenID is connected to another user.
|
||||
#: actions/openidsettings.php:319
|
||||
#: actions/openidsettings.php:318
|
||||
msgid "That OpenID does not belong to you."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Success message after removing an OpenID.
|
||||
#: actions/openidsettings.php:323
|
||||
#: actions/openidsettings.php:322
|
||||
msgid "OpenID removed."
|
||||
msgstr ""
|
||||
|
||||
#: actions/openidsettings.php:343
|
||||
#: actions/openidsettings.php:342
|
||||
msgid "Synchronized OpenID."
|
||||
msgstr ""
|
||||
|
||||
#: actions/openidsettings.php:375
|
||||
#: actions/openidsettings.php:374
|
||||
msgid "OpenID preferences saved."
|
||||
msgstr ""
|
||||
|
||||
@@ -670,68 +670,72 @@ msgstr ""
|
||||
msgid "OpenID provider"
|
||||
msgstr ""
|
||||
|
||||
#: openid.php:136
|
||||
#: openid.php:64
|
||||
msgid "Unknown DB type for OpenID."
|
||||
msgstr ""
|
||||
|
||||
#: openid.php:161
|
||||
msgid "No valid URL provided for OpenID."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin server error.
|
||||
#: openid.php:143
|
||||
#: openid.php:168
|
||||
msgid "Cannot instantiate OpenID consumer object."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin message. Given when an OpenID is not valid.
|
||||
#: openid.php:154
|
||||
#: openid.php:179
|
||||
msgid "Not a valid OpenID."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin server error. Given when the OpenID authentication request fails.
|
||||
#. TRANS: %s is the failure message.
|
||||
#: openid.php:159
|
||||
#: openid.php:184
|
||||
#, php-format
|
||||
msgid "OpenID failure: %s."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin server error. Given when the OpenID authentication request cannot be redirected.
|
||||
#. TRANS: %s is the failure message.
|
||||
#: openid.php:208
|
||||
#: openid.php:233
|
||||
#, php-format
|
||||
msgid "Could not redirect to server: %s."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin user instructions.
|
||||
#: openid.php:246
|
||||
#: openid.php:271
|
||||
msgid ""
|
||||
"This form should automatically submit itself. If not, click the submit "
|
||||
"button to go to your OpenID provider."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin server error.
|
||||
#: openid.php:282
|
||||
#: openid.php:307
|
||||
msgid "Error saving the profile."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin server error.
|
||||
#: openid.php:294
|
||||
#: openid.php:319
|
||||
msgid "Error saving the user."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin client exception (403).
|
||||
#: openid.php:324
|
||||
#: openid.php:349
|
||||
msgid "Unauthorized URL used for OpenID login."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: Title
|
||||
#: openid.php:372
|
||||
#: openid.php:397
|
||||
msgid "OpenID Login Submission"
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin message used while requesting authorization user's OpenID login provider.
|
||||
#: openid.php:383
|
||||
#: openid.php:408
|
||||
msgid "Requesting authorization from your login provider..."
|
||||
msgstr ""
|
||||
|
||||
#. TRANS: OpenID plugin message. User instruction while requesting authorization user's OpenID login provider.
|
||||
#: openid.php:387
|
||||
#: openid.php:412
|
||||
msgid ""
|
||||
"If you are not redirected to your login provider in a few seconds, try "
|
||||
"pushing the button below."
|
||||
|
@@ -35,11 +35,34 @@ define('OPENID_COOKIE_KEY', 'lastusedopenid');
|
||||
function oid_store()
|
||||
{
|
||||
static $store = null;
|
||||
if (!$store) {
|
||||
// Can't be called statically
|
||||
$user = new User();
|
||||
$conn = $user->getDatabaseConnection();
|
||||
$store = new Auth_OpenID_MySQLStore($conn);
|
||||
if (is_null($store)) {
|
||||
// To create a new Database connection is an absolute must
|
||||
// because database is in transaction (auto-commit = false)
|
||||
// mode during OpenID operation
|
||||
// Is a must because our Internal Session Handler uses database
|
||||
// and depends on auto-commit = true
|
||||
$dsn = common_config('db', 'database');
|
||||
$options = PEAR::getStaticProperty('DB', 'options');
|
||||
|
||||
if (!is_array($options)) {
|
||||
$options = [];
|
||||
}
|
||||
$db = DB::connect($dsn, $options);
|
||||
|
||||
if (PEAR::isError($db)) {
|
||||
throw new ServerException($db->getMessage());
|
||||
}
|
||||
|
||||
switch (common_config('db', 'type')) {
|
||||
case 'mysql':
|
||||
$store = new Auth_OpenID_MySQLStore($db);
|
||||
break;
|
||||
case 'postgresql':
|
||||
$store = new Auth_OpenID_PostgreSQLStore($db);
|
||||
break;
|
||||
default:
|
||||
throw new ServerException(_m('Unknown DB type for OpenID.'));
|
||||
}
|
||||
}
|
||||
return $store;
|
||||
}
|
||||
@@ -47,6 +70,8 @@ function oid_store()
|
||||
function oid_consumer()
|
||||
{
|
||||
$store = oid_store();
|
||||
// No need to declare a Yadis Session Handler
|
||||
common_ensure_session(); // This is transparent to OpenID's eyes
|
||||
$consumer = new Auth_OpenID_Consumer($store);
|
||||
return $consumer;
|
||||
}
|
||||
@@ -197,7 +222,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
|
||||
//
|
||||
// Since the GET should always work anyway, we'll just take out the
|
||||
// autosubmitter for now.
|
||||
//
|
||||
//
|
||||
//if ($auth_request->shouldSendRedirect()) {
|
||||
$redirect_url = $auth_request->redirectURL($trust_root,
|
||||
$process_url,
|
||||
|
Reference in New Issue
Block a user