diff options
author | Brion Vibber <brion@pobox.com> | 2010-05-19 12:51:25 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-05-19 12:51:25 -0700 |
commit | 7005ef66617b265ddccdd9082c2368bf014a7e83 (patch) | |
tree | 52f853c4d47063f0af488a7ff5fb52df50b430bb /plugins/OpenID/openid.php | |
parent | 48dc899acb9a0ac87140353092dab1f5e67753d8 (diff) | |
parent | a39a934dd4a133bad6e76fa9a5018cedcb70225c (diff) |
Merge branch 'testing' into 0.9.x
Conflicts:
plugins/OpenID/openidlogin.php
Diffstat (limited to 'plugins/OpenID/openid.php')
-rw-r--r-- | plugins/OpenID/openid.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php index 68b5c29e2..4dc924695 100644 --- a/plugins/OpenID/openid.php +++ b/plugins/OpenID/openid.php @@ -168,6 +168,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); @@ -298,6 +307,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; |