[feature/oauth] Additional work on implementing login

PHPBB3-11673
This commit is contained in:
Joseph Warner 2013-07-13 11:19:35 -04:00
parent 65485253c9
commit 1e38be3fa9

View file

@ -46,7 +46,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
*/ */
public function login($username, $password) public function login($username, $password)
{ {
if (!$this->request->is_set_post('oauth_service')) // Requst the name of the OAuth service
$service = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST);
if ($service === '')
{ {
return array( return array(
'status' => LOGIN_ERROR_EXTERNAL_AUTH, 'status' => LOGIN_ERROR_EXTERNAL_AUTH,
@ -55,19 +57,23 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
); );
} }
$serviceFactory = new \OAuth\ServiceFactory(); // Get the service credentials for the given service
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); $service_credentials = $this->get_credentials($service);
$currentUri = $uriFactory->createFromSuperGlobalArray((array)$_SERVER);
$currentUri->setQuery('');
$service_factory = new \OAuth\ServiceFactory();
$uri_factory = new \OAuth\Common\Http\Uri\UriFactory();
$current_uri = $uri_factory->createFromSuperGlobalArray((array)$_SERVER);
$current_uri->setQuery('');
// In-memory storage // In-memory storage
$storage = new Memory(); $storage = new Memory();
// Setup the credentials for the requests // Setup the credentials for the requests
$credentials = new Credentials( $credentials = new Credentials(
$servicesCredentials['github']['key'], $service_credentials['key'],
$servicesCredentials['github']['secret'], $service_credentials['secret'],
$currentUri->getAbsoluteUri() $current_uri->getAbsoluteUri()
); );
if ($this->request->is_set('code', phpbb_request_interface::GET)) if ($this->request->is_set('code', phpbb_request_interface::GET))
@ -83,14 +89,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
*/ */
protected function get_service_credentials($service) protected function get_service_credentials($service)
{ {
return $service_credentials[$service]; return array(
} 'key' => $this->config['auth_oauth_' . $service . '_key'],
'secret' => $this->config['auth_oauth_' . $service . '_secret'],
/** );
*
*/
public function get_credentials()
{
return array();
} }
} }