[feature/oauth] Create OAuth service classes

PHPBB3-11673
This commit is contained in:
Joseph Warner 2013-07-14 15:16:34 -04:00
parent 00d0e10200
commit 947aa2b6b4
16 changed files with 442 additions and 31 deletions

View file

@ -220,37 +220,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
return $this->service[$service_name]; return $this->service[$service_name];
} }
/**
* Returns the scopes of the service required for authentication
*
* @param string $service_name
* @return array An array of the scopes required from the service
*/
protected function get_scopes($service_name)
{
$scopes = array();
switch ($service_name)
{
case 'GitHub':
$scopes[] = 'user';
break;
case 'google':
$scopes[] = 'userinfo_email';
$scopes[] = 'userinfo_profile';
break;
case 'instagram':
case 'microsoft':
$scopes[] = 'basic';
break;
case 'linkedin':
$scopes[] = 'r_basicprofile';
break;
}
return $scopes;
}
/** /**
* Returns the path desired of the service * Returns the path desired of the service
* *

View file

@ -0,0 +1,32 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Bitly OAuth service
*
* @package auth
*/
abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_provider_oauth_service_interface
{
/**
* {@inheritdoc}
*/
public function get_auth_scope()
{
return array();
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Bitly OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Box OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_box extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Facebook OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* FitBit OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_box extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* FourSquare OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_foursquare extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,34 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* GitHub OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_github extends phpbb_auth_provider_oauth_service_base
{
/**
* {@inheritdoc}
*/
public function get_auth_scope()
{
return array(
'user',
);
}
}

View file

@ -0,0 +1,35 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Google OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth_service_base
{
/**
* {@inheritdoc}
*/
public function get_auth_scope()
{
return array(
'userinfo_email',
'userinfo_profile',
);
}
}

View file

@ -0,0 +1,34 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* instragram OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_instagram extends phpbb_auth_provider_oauth_service_base
{
/**
* {@inheritdoc}
*/
public function get_auth_scope()
{
return array(
'basic',
);
}
}

View file

@ -0,0 +1,31 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* OAuth service interface
*
* @package auth
*/
interface phpbb_auth_provider_oauth_service_interface
{
/**
* Returns an array of the scopes necessary for auth
*
* @return array An array of the required scopes
*/
public function get_auth_scope();
}

View file

@ -0,0 +1,34 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* LinkedIn OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_linkedin extends phpbb_auth_provider_oauth_service_base
{
/**
* {@inheritdoc}
*/
public function get_auth_scope()
{
return array(
'r_basicprofile',
);
}
}

View file

@ -0,0 +1,34 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Microsoft OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_microsoft extends phpbb_auth_provider_oauth_service_base
{
/**
* {@inheritdoc}
*/
public function get_auth_scope()
{
return array(
'basic',
);
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* SoundCloud OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_soundcloud extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Tumblr OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_tumblr extends phpbb_auth_provider_oauth_service_base
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Twitter OAuth service
*
* @package auth
*/
class phpbb_auth_provider_oauth_service_twitter extends phpbb_auth_provider_oauth_service_base
{
}