X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOpenID%2Fopenid.php;h=4ce350f7737a56d0480e6440d4e1f9a6ef0a0148;hb=b1c5cb9db99993fcea7c060bffa6d5d50f22a41f;hp=cdeedbf4d02a1c5ad3e29179d23324fb07c42d16;hpb=9193c110f14e09523791683e7799a45163b881c2;p=quix0rs-gnu-social.git
diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php
index cdeedbf4d0..4ce350f773 100644
--- a/plugins/OpenID/openid.php
+++ b/plugins/OpenID/openid.php
@@ -134,6 +134,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
$consumer = oid_consumer();
if (!$consumer) {
+ // TRANS: OpenID plugin server error.
common_server_error(_m('Cannot instantiate OpenID consumer object.'));
return false;
}
@@ -144,8 +145,13 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
// Handle failure status return values.
if (!$auth_request) {
+ common_log(LOG_ERR, __METHOD__ . ": mystery fail contacting $openid_url");
+ // TRANS: OpenID plugin message. Given when an OpenID is not valid.
return _m('Not a valid OpenID.');
} else if (Auth_OpenID::isFailure($auth_request)) {
+ common_log(LOG_ERR, __METHOD__ . ": OpenID fail to $openid_url: $auth_request->message");
+ // TRANS: OpenID plugin server error. Given when the OpenID authentication request fails.
+ // TRANS: %s is the failure message.
return sprintf(_m('OpenID failure: %s'), $auth_request->message);
}
@@ -164,6 +170,15 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
$auth_request->addExtension($sreg_request);
}
+ $requiredTeam = common_config('openid', 'required_team');
+ if ($requiredTeam) {
+ // LaunchPad OpenID extension
+ $team_request = new Auth_OpenID_TeamsRequest(array($requiredTeam));
+ if ($team_request) {
+ $auth_request->addExtension($team_request);
+ }
+ }
+
$trust_root = common_root_url(true);
$process_url = common_local_url($returnto);
@@ -173,6 +188,8 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
$immediate);
if (!$redirect_url) {
} else if (Auth_OpenID::isFailure($redirect_url)) {
+ // TRANS: OpenID plugin server error. Given when the OpenID authentication request cannot be redirected.
+ // TRANS: %s is the failure message.
return sprintf(_m('Could not redirect to server: %s'), $redirect_url->message);
} else {
common_redirect($redirect_url, 303);
@@ -191,6 +208,8 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
// Display an error if the form markup couldn't be generated;
// otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) {
+ // TRANS: OpenID plugin server error if the form markup could not be generated.
+ // TRANS: %s is the failure message.
common_server_error(sprintf(_m('Could not create OpenID form: %s'), $form_html->message));
} else {
$action = new AutosubmitAction(); // see below
@@ -207,6 +226,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
function _oid_print_instructions()
{
common_element('div', 'instructions',
+ // TRANS: OpenID plugin user instructions.
_m('This form should automatically submit itself. '.
'If not, click the submit button to go to your '.
'OpenID provider.'));
@@ -242,6 +262,7 @@ function oid_update_user($user, $sreg)
# XXX save timezone if it's passed
if (!$profile->update($orig_profile)) {
+ // TRANS: OpenID plugin server error.
common_server_error(_m('Error saving the profile.'));
return false;
}
@@ -253,6 +274,7 @@ function oid_update_user($user, $sreg)
}
if (!$user->update($orig_user)) {
+ // TRANS: OpenID plugin server error.
common_server_error(_m('Error saving the user.'));
return false;
}
@@ -282,6 +304,7 @@ function oid_assert_allowed($url)
return;
}
}
+ // TRANS: OpenID plugin client exception (403).
throw new ClientException(_m("Unauthorized URL used for OpenID login."), 403);
}
}
@@ -289,6 +312,33 @@ function oid_assert_allowed($url)
return;
}
+/**
+ * Check the teams available in the given OpenID response
+ * Using Launchpad's OpenID teams extension
+ *
+ * @return boolean whether this user is acceptable
+ */
+function oid_check_teams($response)
+{
+ $requiredTeam = common_config('openid', 'required_team');
+ if ($requiredTeam) {
+ $team_resp = new Auth_OpenID_TeamsResponse($response);
+ if ($team_resp) {
+ $teams = $team_resp->getTeams();
+ } else {
+ $teams = array();
+ }
+
+ $match = in_array($requiredTeam, $teams);
+ $is = $match ? 'is' : 'is not';
+ common_log(LOG_DEBUG, "Remote user $is in required team $requiredTeam: [" . implode(', ', $teams) . "]");
+
+ return $match;
+ }
+
+ return true;
+}
+
class AutosubmitAction extends Action
{
var $form_html = null;
@@ -302,6 +352,7 @@ class AutosubmitAction extends Action
function title()
{
+ // TRANS: Title
return _m('OpenID Login Submission');
}
@@ -312,9 +363,11 @@ class AutosubmitAction extends Action
$this->element('img', array('src' => Theme::path('images/icons/icon_processing.gif', 'base'),
// for some reason the base CSS sets s as block display?!
'style' => 'display: inline'));
+ // TRANS: OpenID plugin message used while requesting authorization user's OpenID login provider.
$this->text(_m('Requesting authorization from your login provider...'));
$this->raw('
'); + // TRANS: OpenID plugin message. User instruction while requesting authorization user's OpenID login provider. $this->text(_m('If you are not redirected to your login provider in a few seconds, try pushing the button below.')); $this->raw('
'); $this->raw($this->form_html);