diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 16:07:11 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 16:07:26 -0400 |
commit | d21ab4f629342d9f1bb46f489f166c9016ebe72b (patch) | |
tree | 9953a9c07476fe7cf7f4045ca683891cb7980272 | |
parent | 3d55e5faa91f0161bc020720a81b50171b30f49d (diff) | |
download | forums-d21ab4f629342d9f1bb46f489f166c9016ebe72b.tar forums-d21ab4f629342d9f1bb46f489f166c9016ebe72b.tar.gz forums-d21ab4f629342d9f1bb46f489f166c9016ebe72b.tar.bz2 forums-d21ab4f629342d9f1bb46f489f166c9016ebe72b.tar.xz forums-d21ab4f629342d9f1bb46f489f166c9016ebe72b.zip |
[feature/oauth] Update the OAuth service interface
PHPBB3-11673
5 files changed, 47 insertions, 2 deletions
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6526667794..4266a8de0d 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -398,7 +398,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->service_providers[$service_name]->set_external_service_provider($service); // The user has already authenticated successfully, request to authenticate again - $unique_id = $this->service_providers[$service_name]->perform_auth_link(); + $unique_id = $this->service_providers[$service_name]->perform_token_auth(); // Insert into table, they will be able to log in after this $data = array( diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index b6b99c0850..9b8e7ebb03 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -79,4 +79,22 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ // Return the unique identifier returned from bitly return $result['data']['login']; } + + /** + * {@inheritdoc} + */ + public function perform_token_auth() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // Send a request with it + $result = json_decode( $this->service_provider->request('user/info'), true ); + + // Return the unique identifier returned from bitly + return $result['data']['login']; + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 4758ae11f8..16919081cc 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -79,4 +79,22 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau // Return the unique identifier returned from bitly return $result['id']; } + + /** + * {@inheritdoc} + */ + public function perform_token_auth() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // Send a request with it + $result = json_decode( $this->service_provider->request('/me'), true ); + + // Return the unique identifier returned from bitly + return $result['id']; + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index c5de1e01d2..b49a833cce 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -94,7 +94,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth /** * {@inheritdoc} */ - public function perform_auth_link() + public function perform_token_auth() { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) { diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index a69148695d..0d6ae7417f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -58,6 +58,15 @@ interface phpbb_auth_provider_oauth_service_interface public function perform_auth_login(); /** + * Returns the results of the authentication in json format + * Use this function when the user already has an access token + * + * @return string The unique identifier returned by the service provider + * that is used to authenticate the user with phpBB. + */ + public function perform_token_auth(); + + /** * Sets the external library service provider * * @param \OAuth\Common\Service\ServiceInterface $service |