summaryrefslogtreecommitdiff
path: root/plugins/OpenID/openid.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-05-18 13:37:46 -0700
committerBrion Vibber <brion@pobox.com>2010-05-18 13:37:46 -0700
commitd0ba34e0f32ac71b552302ec875943e0e9236720 (patch)
tree832455e96f8a6b81dd6279f20ae7f38b7bc60a8b /plugins/OpenID/openid.php
parentd5b4df4097c2d64e52f249042038ddbf99769b6c (diff)
parent7c828ae5f8ab20f0daa8a1482fadce9b3e858975 (diff)
Merge branch 'openid-teams' into testing
Diffstat (limited to 'plugins/OpenID/openid.php')
-rw-r--r--plugins/OpenID/openid.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php
index 4ec336e1c..5ee9343d2 100644
--- a/plugins/OpenID/openid.php
+++ b/plugins/OpenID/openid.php
@@ -164,6 +164,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);
@@ -286,6 +295,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;