[feature/oauth] Define method to perform login actions for a provider

PHPB3-11673
This commit is contained in:
Joseph Warner 2013-07-15 15:21:20 -04:00
parent 8641127da5
commit 47b998ae48
3 changed files with 39 additions and 9 deletions

View file

@ -128,15 +128,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
if ($this->request->is_set('code', phpbb_request_interface::GET)) if ($this->request->is_set('code', phpbb_request_interface::GET))
{ {
// This was a callback request from the service provider $this->services[$service_name]->set_external_service_provider($service);
$service->requestAccessToken( $_GET['code'] ); $result = $this->services[$service_name]->perform_auth_login();
// Send a request with it
$path = $this->get_path($service_name);
if ($path)
{
$result = json_decode( $service->request($path), true );
}
// Perform authentication // Perform authentication
} else { } else {

View file

@ -22,6 +22,21 @@ if (!defined('IN_PHPBB'))
*/ */
abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_provider_oauth_service_interface abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_provider_oauth_service_interface
{ {
/**
* External OAuth service provider
*
* @var \OAuth\Common\Service\ServiceInterface
*/
protected $service_provider;
/**
* {@inheritdoc}
*/
public function get_external_service_provider()
{
return $this->service_provider;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -29,4 +44,12 @@ abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_prov
{ {
return array(); return array();
} }
/**
* {@inheritdoc}
*/
public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider)
{
$this->service_provider = $service;
}
} }

View file

@ -29,6 +29,13 @@ interface phpbb_auth_provider_oauth_service_interface
*/ */
public function get_auth_scope(); public function get_auth_scope();
/**
* Returns the external library service provider once it has been set
*
* @param \OAuth\Common\Service\ServiceInterface|null
*/
public function get_external_service_provider();
/** /**
* Returns an array containing the service credentials belonging to requested * Returns an array containing the service credentials belonging to requested
* service. * service.
@ -41,4 +48,11 @@ interface phpbb_auth_provider_oauth_service_interface
* ) * )
*/ */
public function get_service_credentials(); public function get_service_credentials();
/**
* Sets the external library service provider
*
* @param \OAuth\Common\Service\ServiceInterface $service
*/
public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider);
} }