From 3c11052fb3896b43685f596dc6e52f9cc07d6807 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 10:54:55 -0400 Subject: [feature/auth-refactor] Have a base auth class PHPBB3-9734 --- phpBB/includes/auth/provider/apache.php | 19 +-------- phpBB/includes/auth/provider/base.php | 69 +++++++++++++++++++++++++++++++++ phpBB/includes/auth/provider/db.php | 43 +------------------- phpBB/includes/auth/provider/ldap.php | 27 +------------ 4 files changed, 75 insertions(+), 83 deletions(-) create mode 100644 phpBB/includes/auth/provider/base.php (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/apache.php b/phpBB/includes/auth/provider/apache.php index 5f6f2862b6..e0217725d6 100644 --- a/phpBB/includes/auth/provider/apache.php +++ b/phpBB/includes/auth/provider/apache.php @@ -20,7 +20,8 @@ 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 + implements phpbb_auth_provider_interface { /** * Apache Authentication Constructor @@ -256,20 +257,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; - } } diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php new file mode 100644 index 0000000000..e053a1829b --- /dev/null +++ b/phpBB/includes/auth/provider/base.php @@ -0,0 +1,69 @@ +php_ext = $php_ext; } - /** - * {@inheritdoc} - */ - public function init() - { - return; - } - /** * {@inheritdoc} */ @@ -302,36 +295,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; - } } diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index f67c1e9247..dbb569f466 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -22,7 +22,8 @@ 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 + implements phpbb_auth_provider_interface { /** * LDAP Authentication Constructor @@ -283,14 +284,6 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface ); } - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - /** * {@inheritdoc} */ @@ -367,20 +360,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; - } } -- cgit v1.2.1 From 69c1b1aea89f3c705c19d69aab70c35a7d09747a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 11:06:34 -0400 Subject: [feature/auth-refactor] Prevent fatal error in php < 5.3.23 PHPBB3-9734 --- phpBB/includes/auth/provider/base.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index e053a1829b..7961bf4dde 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -30,11 +30,6 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface return; } - /** - * {@inheritdoc} - */ - abstract public function login($username, $password); - /** * {@inheritdoc} */ -- cgit v1.2.1 From 021eb083abc1fe11d18d756adf12f72b903b13ed Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 11:09:25 -0400 Subject: [feature/auth-refactor] Remove implements on classes extending base PHPBB3-9734 --- phpBB/includes/auth/provider/apache.php | 1 - phpBB/includes/auth/provider/db.php | 3 +-- phpBB/includes/auth/provider/ldap.php | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/apache.php b/phpBB/includes/auth/provider/apache.php index e0217725d6..2e80436f78 100644 --- a/phpBB/includes/auth/provider/apache.php +++ b/phpBB/includes/auth/provider/apache.php @@ -21,7 +21,6 @@ if (!defined('IN_PHPBB')) * @package auth */ class phpbb_auth_provider_apache extends phpbb_auth_provider_base - implements phpbb_auth_provider_interface { /** * Apache Authentication Constructor diff --git a/phpBB/includes/auth/provider/db.php b/phpBB/includes/auth/provider/db.php index b9b808cb5d..0934c56d9b 100644 --- a/phpBB/includes/auth/provider/db.php +++ b/phpBB/includes/auth/provider/db.php @@ -22,8 +22,7 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_db extends phpbb_auth_provider_base - implements phpbb_auth_provider_interface +class phpbb_auth_provider_db extends phpbb_auth_provider_base { /** diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index dbb569f466..e10986abf0 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -23,7 +23,6 @@ if (!defined('IN_PHPBB')) * @package auth */ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base - implements phpbb_auth_provider_interface { /** * LDAP Authentication Constructor -- cgit v1.2.1 From ccef1ae5ab406f6e6c4110467e1077ab58135e30 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 11:26:59 -0400 Subject: [feature/auth-refactor] Change 'must' to 'should' PHPBB3-9734 --- phpBB/includes/auth/provider/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index 7961bf4dde..307988f00a 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -16,7 +16,7 @@ if (!defined('IN_PHPBB')) } /** - * Base authentication provider class that all other providers must implement. + * Base authentication provider class that all other providers should implement. * * @package auth */ -- cgit v1.2.1 From 177e340764ccb929d3ebfe978ce05ceba271f479 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 11:31:50 -0400 Subject: [feature/auth-refactor] Code style fix for doc blocks PHPBB3-9734 --- phpBB/includes/auth/provider/base.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index 307988f00a..046674e55e 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -16,47 +16,47 @@ if (!defined('IN_PHPBB')) } /** - * Base authentication provider class that all other providers should implement. - * - * @package auth - */ +* Base authentication provider class that all other providers should implement. +* +* @package auth +*/ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function init() { return; } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function autologin() { return; } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function acp($new) { return; } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function logout($data, $new_session) { return; } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function validate_session($user) { return; -- cgit v1.2.1 From e674838d6951adb4df76195863df918f3b5852fd Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 12:06:48 -0400 Subject: [feature/auth-refactor] Remove full stop PHPBB3-9734 --- phpBB/includes/auth/provider/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index 046674e55e..f28f352e2c 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -16,7 +16,7 @@ if (!defined('IN_PHPBB')) } /** -* Base authentication provider class that all other providers should implement. +* Base authentication provider class that all other providers should implement * * @package auth */ -- cgit v1.2.1 From b0e6b1dd98a6458d9a6d1c40369dfd8402411077 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 5 Jul 2013 13:31:05 -0400 Subject: [ticket/11626] Create get_acp_template method for auth providers PHPBB3-11626 --- phpBB/includes/auth/provider/base.php | 8 ++++++++ phpBB/includes/auth/provider/interface.php | 13 +++++++++++++ phpBB/includes/auth/provider/ldap.php | 20 +++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index f28f352e2c..d1de9647df 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -46,6 +46,14 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface return; } + /** + * {@inheritdoc} + */ + public function get_acp_template($new_config) + { + return; + } + /** * {@inheritdoc} */ diff --git a/phpBB/includes/auth/provider/interface.php b/phpBB/includes/auth/provider/interface.php index 2d1935f8f0..fe2415ee25 100644 --- a/phpBB/includes/auth/provider/interface.php +++ b/phpBB/includes/auth/provider/interface.php @@ -71,6 +71,19 @@ interface phpbb_auth_provider_interface */ public function acp($new); + /** + * This function updates the template with variables related to the acp + * options with whatever configuraton values are passed to it as an array. + * It then returns the name of the acp file related to this authentication + * provider. + * @param array $new_config Contains the new configuration values that + * have been set in acp_board. + * @return string|null Returns null if not implemented or a string + * containing the name of the acp tempalte file for + * the authentication provider. + */ + public function get_acp_template($new_config); + /** * Performs additional actions during logout. * diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index e10986abf0..9fc064a847 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -30,8 +30,9 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base * @param phpbb_db_driver $db * @param phpbb_config $config * @param phpbb_user $user + * @param phpbb_template $template */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user, phpbb_template $template) { $this->db = $db; $this->config = $config; @@ -331,6 +332,23 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base ); } + /** + * {@inheritdoc} + */ + public function get_acp_template($new_config) + { + $this->template->assign_vars(array( + 'AUTH_LDAP_DN' => $new_config['ldap_base_dn'], + 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], + 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'], + 'AUTH_LDAP_PORT' => $new_config['ldap_port'], + 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], + 'AUTH_LDAP_UID' => $new_config['ldap_uid'], + 'AUTH_LDAP_USER' => $new_config['ldap_user'], + 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], + )); + } + /** * Generates a filter string for ldap_search to find a user * -- cgit v1.2.1 From 80eb95bbb7685995ccc2cfa46280aef6e8ef024a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 8 Jul 2013 13:51:00 -0400 Subject: [ticket/11626] LDAP Auth ACP Template File PHPBB3-11626 --- phpBB/includes/auth/provider/ldap.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index 9fc064a847..b063f6d682 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -347,6 +347,8 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base 'AUTH_LDAP_USER' => $new_config['ldap_user'], 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], )); + + return 'auth_provider_ldap.html'; } /** -- cgit v1.2.1 From 29b472c2e5c8a878b592c53733cc57961d60a0af Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 8 Jul 2013 13:59:24 -0400 Subject: [ticket/11626] Include the template file in acp_board PHPBB3-11626 --- phpBB/includes/auth/provider/ldap.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index b063f6d682..0164a60f2e 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -37,6 +37,7 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base $this->db = $db; $this->config = $config; $this->user = $user; + $this->template = $template; } /** -- cgit v1.2.1 From 60100b62f35cde7f5beafefbe9ff1a10ee81faa4 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 8 Jul 2013 14:02:53 -0400 Subject: [ticket/11626] Change interface to match functionality Changes the interface so that it matches the new functionality of phpbb_provider_auth_interface::acp(). PHPBB3-11626 --- phpBB/includes/auth/provider/base.php | 2 +- phpBB/includes/auth/provider/interface.php | 10 ++----- phpBB/includes/auth/provider/ldap.php | 42 +++--------------------------- 3 files changed, 6 insertions(+), 48 deletions(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index d1de9647df..7eaf8bb2d3 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -41,7 +41,7 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface /** * {@inheritdoc} */ - public function acp($new) + public function acp() { return; } diff --git a/phpBB/includes/auth/provider/interface.php b/phpBB/includes/auth/provider/interface.php index fe2415ee25..40c48026cf 100644 --- a/phpBB/includes/auth/provider/interface.php +++ b/phpBB/includes/auth/provider/interface.php @@ -60,16 +60,10 @@ interface phpbb_auth_provider_interface * This function is used to output any required fields in the authentication * admin panel. It also defines any required configuration table fields. * - * @param array $new Contains the new configuration values that have - * been set in acp_board. * @return array|null Returns null if not implemented or an array of the - * form: - * array( - * 'tpl' => string - * 'config' => array - * ) + * configuration fields of the provider. */ - public function acp($new); + public function acp(); /** * This function updates the template with variables related to the acp diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index 0164a60f2e..288fb617f5 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -288,48 +288,12 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base /** * {@inheritdoc} */ - public function acp($new) - { - $tpl = ' - -
-

' . $this->user->lang['LDAP_SERVER_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_PORT_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_DN_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_UID_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_USER_FILTER_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_EMAIL_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_USER_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['LDAP_PASSWORD_EXPLAIN'] . '
-
-
- '; + public function acp() + { // These are fields required in the config table return array( - 'tpl' => $tpl, - 'config' => array('ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password') + 'ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password', ); } -- cgit v1.2.1 From 631ce22f2c33999229bf05af35e025fb8d399417 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 12 Jul 2013 15:53:36 -0400 Subject: [ticket/11626] Remove LDAP dependency on template Returns template vars rather than requiring the template. PHPBB3-11626 --- phpBB/includes/auth/provider/interface.php | 11 ++++++++--- phpBB/includes/auth/provider/ldap.php | 31 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/interface.php b/phpBB/includes/auth/provider/interface.php index 40c48026cf..47043bc107 100644 --- a/phpBB/includes/auth/provider/interface.php +++ b/phpBB/includes/auth/provider/interface.php @@ -72,9 +72,14 @@ interface phpbb_auth_provider_interface * provider. * @param array $new_config Contains the new configuration values that * have been set in acp_board. - * @return string|null Returns null if not implemented or a string - * containing the name of the acp tempalte file for - * the authentication provider. + * @return array|null Returns null if not implemented or an array with + * the template file name and an array of the vars + * that the template needs that must conform to the + * following example: + * array( + * 'TEMPLATE_FILE' => string, + * 'TEMPLATE_VARS' => array(...), + * ) */ public function get_acp_template($new_config); diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index 288fb617f5..56f9c23d55 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -30,14 +30,12 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base * @param phpbb_db_driver $db * @param phpbb_config $config * @param phpbb_user $user - * @param phpbb_template $template */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user, phpbb_template $template) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user) { $this->db = $db; $this->config = $config; $this->user = $user; - $this->template = $template; } /** @@ -302,18 +300,21 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base */ public function get_acp_template($new_config) { - $this->template->assign_vars(array( - 'AUTH_LDAP_DN' => $new_config['ldap_base_dn'], - 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], - 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'], - 'AUTH_LDAP_PORT' => $new_config['ldap_port'], - 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], - 'AUTH_LDAP_UID' => $new_config['ldap_uid'], - 'AUTH_LDAP_USER' => $new_config['ldap_user'], - 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], - )); - - return 'auth_provider_ldap.html'; + $this->template->assign_vars(); + + return array( + 'TEMPLATE_FILE' => 'auth_provider_ldap.html', + 'TEMPLATE_VARS' => array( + 'AUTH_LDAP_DN' => $new_config['ldap_base_dn'], + 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], + 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'], + 'AUTH_LDAP_PORT' => $new_config['ldap_port'], + 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], + 'AUTH_LDAP_UID' => $new_config['ldap_uid'], + 'AUTH_LDAP_USER' => $new_config['ldap_user'], + 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], + ), + ); } /** -- cgit v1.2.1 From 64308f41b054d11ae267a58e04821b7b1e31af91 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 12 Jul 2013 15:57:35 -0400 Subject: [ticket/11626] Remove last reference to template in ldap PHPBB3-11626 --- phpBB/includes/auth/provider/ldap.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/includes/auth/provider') diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index 56f9c23d55..0196529408 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -300,8 +300,6 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base */ public function get_acp_template($new_config) { - $this->template->assign_vars(); - return array( 'TEMPLATE_FILE' => 'auth_provider_ldap.html', 'TEMPLATE_VARS' => array( -- cgit v1.2.1