diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-13 13:50:06 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-14 14:22:42 -0400 |
commit | 37f099b014ea34378096c50cf898c060bd3f0d42 (patch) | |
tree | d9b5df069335d78c7d706a87b6e32fb07bbef9c5 /phpBB/includes | |
parent | aa12f6afc52b1b536068512487b0b95690786f22 (diff) | |
download | forums-37f099b014ea34378096c50cf898c060bd3f0d42.tar forums-37f099b014ea34378096c50cf898c060bd3f0d42.tar.gz forums-37f099b014ea34378096c50cf898c060bd3f0d42.tar.bz2 forums-37f099b014ea34378096c50cf898c060bd3f0d42.tar.xz forums-37f099b014ea34378096c50cf898c060bd3f0d42.zip |
[feature/oauth] Document and rearrange methods
PHPBB3-11673
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/auth/provider/oauth.php | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index cdfcace5b2..267105e6b6 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -108,6 +108,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } + // Get the service credentials for the given service + $service_credentials = $this->get_credentials($service_name); + + // Check that the service has settings + if ($service_credentials['key'] == false || $service_credentials['secret'] == false) + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + if ($this->request->is_set('code', phpbb_request_interface::GET)) { // Second pass: request access token, authenticate with phpBB @@ -117,7 +130,16 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } /** + * Returns an array containing the service credentials belonging to requested + * service. * + * @param string $service_name The name of the service + * @return array An array containing the 'key' and the 'secret' of the + * service in the form: + * array( + * 'key' => string + * 'secret' => string + * ) */ protected function get_service_credentials($service_name) { @@ -127,6 +149,12 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } + /** + * Returns the cached current_uri object or creates and caches it if it is + * not already created + * + * @return \OAuth\Common\Http\Uri\UriInterface + */ protected function get_current_uri() { if ($this->current_uri) @@ -145,30 +173,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base /** * Returns the cached service object or creates a new one * - * @param string $service_name The name of the service - * @param array $scope The scope of the request against the api. + * @param string $service_name The name of the service + * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} + * @param array $scope The scope of the request against + * the api. * @return \OAuth\Common\Service\ServiceInterface */ - protected function get_service($service_name, array $scopes = array()) + protected function get_service($service_name, array $service_credentials, array $scopes = array()) { if ($this->service) { return $this->service; } - // Get the service credentials for the given service - $service_credentials = $this->get_credentials($service_name); - - // Check that the service has settings - if ($service_credentials['key'] == false || $service_credentials['secret'] == false) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - $storage = new phpbb_auth_oauth_token_storage($this->driver); $current_uri = $this->get_current_uri(); |