mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
Merge pull request #1515 from Hardolaf/feature/auth-refactor
[feature/auth-refactor] Use a base class for all authentication providers
This commit is contained in:
@@ -678,8 +678,12 @@ class acp_board
|
||||
$auth_plugins = array();
|
||||
$auth_providers = $phpbb_container->get('auth.provider_collection');
|
||||
|
||||
foreach($auth_providers as $key => $value)
|
||||
foreach ($auth_providers as $key => $value)
|
||||
{
|
||||
if (!($value instanceof phpbb_auth_provider_interface))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$auth_plugins[] = str_replace('auth.provider.', '', $key);
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
class phpbb_auth_provider_apache implements phpbb_auth_provider_interface
|
||||
class phpbb_auth_provider_apache extends phpbb_auth_provider_base
|
||||
{
|
||||
/**
|
||||
* Apache Authentication Constructor
|
||||
@@ -256,20 +256,4 @@ class phpbb_auth_provider_apache implements phpbb_auth_provider_interface
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acp($new)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
64
phpBB/includes/auth/provider/base.php
Normal file
64
phpBB/includes/auth/provider/base.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base authentication provider class that all other providers should implement
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acp($new)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_session($user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
@@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
||||
class phpbb_auth_provider_db extends phpbb_auth_provider_base
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -45,14 +45,6 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -302,36 +294,4 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acp($new)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_session($user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package auth
|
||||
*/
|
||||
class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
|
||||
class phpbb_auth_provider_ldap extends phpbb_auth_provider_base
|
||||
{
|
||||
/**
|
||||
* LDAP Authentication Constructor
|
||||
@@ -283,14 +283,6 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function autologin()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -367,20 +359,4 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
|
||||
{
|
||||
return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function logout($data, $new_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_session($user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -404,6 +404,12 @@ class phpbb_session
|
||||
$method = basename(trim($config['auth_method']));
|
||||
|
||||
$provider = $phpbb_container->get('auth.provider.' . $method);
|
||||
|
||||
if (!($provider instanceof phpbb_auth_provider_interface))
|
||||
{
|
||||
throw new \RuntimeException($provider . ' must implement phpbb_auth_provider_interface');
|
||||
}
|
||||
|
||||
$ret = $provider->validate_session($this->data);
|
||||
if ($ret !== null && !$ret)
|
||||
{
|
||||
|
Reference in New Issue
Block a user