From 0559d7f58aba72771e5d19c6faeebd459a05a8ab Mon Sep 17 00:00:00 2001 From: Olivier Berger Date: Thu, 24 Mar 2011 16:26:16 +0100 Subject: [PATCH] Factorize decalreconfig in parent --- src/common/include/AuthPlugin.class.php | 6 +++++- .../common/AuthBuiltinPlugin.class.php | 19 ++++++++++++++++--- .../authcas/include/AuthCASPlugin.class.php | 10 +++++++++- .../include/AuthHTTPDPlugin.class.php | 16 +++++++++++++++- .../authldap/include/AuthLDAPPlugin.class.php | 10 +++++++++- 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/common/include/AuthPlugin.class.php b/src/common/include/AuthPlugin.class.php index 5f2fbe2f7..5b5f0616f 100644 --- a/src/common/include/AuthPlugin.class.php +++ b/src/common/include/AuthPlugin.class.php @@ -39,8 +39,10 @@ abstract class ForgeAuthPlugin extends Plugin { * ForgeAuthPlugin() - constructor * */ - function ForgeAuthPlugin() { + function ForgeAuthPlugin($name) { $this->Plugin(); + $this->name = $name; + // Common hooks that can be enabled per plugin: // check_auth_session - is there a valid session? // fetch_authenticated_user - what GFUser is logged in? @@ -52,6 +54,8 @@ function ForgeAuthPlugin() { // close_auth_session - terminate an authentication session $this->saved_user = NULL; + + $this->declareConfigVars(); } // Hook dispatcher diff --git a/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php b/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php index 9f8d012d6..b3b057f70 100644 --- a/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php +++ b/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php @@ -33,9 +33,8 @@ class AuthBuiltinPlugin extends ForgeAuthPlugin { * */ function AuthBuiltinPlugin() { - $this->ForgeAuthPlugin(); + $this->ForgeAuthPlugin('authbuiltin'); - $this->name = 'authbuiltin'; $this->text = 'Built-in authentication'; $this->_addHook('check_auth_session'); @@ -47,7 +46,7 @@ function AuthBuiltinPlugin() { // restrict_roles - filter out unwanted roles $this->_addHook('close_auth_session'); - $this->declareConfigVars(); + //$this->declareConfigVars(); } /** @@ -90,6 +89,20 @@ function displayAuthForm(&$params) { $params['html_snippets'][$this->name] = $result; } + /** + * TODO: Enter description here ... + */ + protected function declareConfigVars() { + parent::declareConfigVars(); + + // Change vs default + forge_define_config_item ('required', $this->name, 'yes'); + forge_set_config_item_bool ('required', $this->name) ; + + // Change vs default + forge_define_config_item ('sufficient', $this->name, 'yes'); + forge_set_config_item_bool ('sufficient', $this->name) ; + } } // Local Variables: diff --git a/src/plugins/authcas/include/AuthCASPlugin.class.php b/src/plugins/authcas/include/AuthCASPlugin.class.php index 612a6e5e7..bd20fb809 100644 --- a/src/plugins/authcas/include/AuthCASPlugin.class.php +++ b/src/plugins/authcas/include/AuthCASPlugin.class.php @@ -44,7 +44,7 @@ function AuthCASPlugin () { //$this->saved_login = ''; //$this->saved_user = NULL; - $this->declareConfigVars(); + //$this->declareConfigVars(); } private static $init = false; @@ -170,6 +170,14 @@ function closeAuthSession($params) { protected function declareConfigVars() { parent::declareConfigVars(); + // Change vs default + forge_define_config_item ('required', $this->name, 'yes'); + forge_set_config_item_bool ('required', $this->name) ; + + // Change vs default + forge_define_config_item ('sufficient', $this->name, 'yes'); + forge_set_config_item_bool ('sufficient', $this->name) ; + forge_define_config_item ('cas_server', $this->name, 'cas.example.com'); forge_define_config_item ('cas_port', $this->name, 443); forge_define_config_item ('cas_version', $this->name, '2.0'); diff --git a/src/plugins/authhttpd/include/AuthHTTPDPlugin.class.php b/src/plugins/authhttpd/include/AuthHTTPDPlugin.class.php index b71d359e1..60adc93b6 100644 --- a/src/plugins/authhttpd/include/AuthHTTPDPlugin.class.php +++ b/src/plugins/authhttpd/include/AuthHTTPDPlugin.class.php @@ -40,7 +40,7 @@ function AuthHTTPDPlugin () { //$this->saved_login = ''; //$this->saved_user = NULL; - $this->declareConfigVars(); + //$this->declareConfigVars(); } private static $init = false; @@ -125,6 +125,20 @@ function closeAuthSession($params) { // No way to close an HTTPD session from the server, unfortunately return true; } + /** + * TODO: Enter description here ... + */ + protected function declareConfigVars() { + parent::declareConfigVars(); + + // Change vs default + forge_define_config_item ('required', $this->name, 'yes'); + forge_set_config_item_bool ('required', $this->name) ; + + // Change vs default + forge_define_config_item ('sufficient', $this->name, 'yes'); + forge_set_config_item_bool ('sufficient', $this->name) ; + } } // Local Variables: diff --git a/src/plugins/authldap/include/AuthLDAPPlugin.class.php b/src/plugins/authldap/include/AuthLDAPPlugin.class.php index bc14befc7..b66e01e5c 100644 --- a/src/plugins/authldap/include/AuthLDAPPlugin.class.php +++ b/src/plugins/authldap/include/AuthLDAPPlugin.class.php @@ -49,7 +49,7 @@ function AuthLDAPPlugin() { $this->saved_password = ''; $this->saved_data = array(); - $this->declareConfigVars(); + //$this->declareConfigVars(); } function syncAccountInfo($params) { @@ -216,6 +216,14 @@ function displayAuthForm(&$params) { protected function declareConfigVars() { parent::declareConfigVars(); + // Change vs default + forge_define_config_item ('required', $this->name, 'yes'); + forge_set_config_item_bool ('required', $this->name) ; + + // Change vs default + forge_define_config_item ('sufficient', $this->name, 'yes'); + forge_set_config_item_bool ('sufficient', $this->name) ; + forge_define_config_item('start_tls', $this->name, 'no'); forge_set_config_item_bool('start_tls', $this->name);