DomCi : update the parameters definitions

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3280 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-12-12 14:49:16 +00:00
parent b55ea95fae
commit 2e535af8d5
8 changed files with 164 additions and 54 deletions

View File

@@ -23,33 +23,39 @@ class authentication
/** Number of authentication maximum by minute */ /** Number of authentication maximum by minute */
public $ratelimitAuth = 3; public $ratelimitAuth = 3;
/** Directory to store the ratelimit files */ /** Directory to store the ratelimit files */
public $ratelimitDir = "/tmp"; public $ratelimitDir = "/tmp";
/** The rest authentication methods. Can be http, session, post. /** The rest authentication methods. Can be http, session, post.
Attention : session case = CSRF ! */ * Attention : session case = CSRF !
*/
public $restMethods = array ("http"); public $restMethods = array ("http");
/** The html authentication methods. Can be http, session, post /** The html authentication methods. Can be http, session, post
* The "post" is already used when using verifAuthLoginPage method (usually * The "post" is already used when using verifAuthLoginPage method (usually
* only in authentication page) * only in authentication page)
*/ */
public $htmlMethods = array ("session"); public $htmlMethods = array ("session");
/** The authentication methods. Can be ldap, sympa...*/ /** The authentication methods. Can be ldap, sympa...*/
public $authMethods = array (); public $authMethods = array ();
/** The authentication servers configuration /** The authentication servers configuration
array ("authXXXX"=>array ( * array ("authXXXX"=>array (
array ("ldapserver"=>"ldaps://annuaire.grenoble.cnrs.fr", * array ("ldapserver"=>"ldaps://annuaire.grenoble.cnrs.fr",
"ldapport"=>636, * "ldapport"=>636,
"ldaptimeout"=>5, * "ldaptimeout"=>5,
"ldapauth"=>"uid=annuaire,ou=people,dc=grenoble,dc=cnrs,dc=fr", * "ldapauth"=>"uid=annuaire,ou=people,dc=grenoble,dc=cnrs,dc=fr",
"ldappwd"=>";authANNUAIRE2013", * "ldappwd"=>";authANNUAIRE2013",
"ldapbase"=>"", * "ldapbase"=>"",
"ldapfilter"=>"(mail=%s)", * "ldapfilter"=>"(mail=%s)",
"ldapfield"=>"mail", * "ldapfield"=>"mail",
"ldapfiltersearch"=>"(objectClass=inetOrgPerson)" * "ldapfiltersearch"=>"(objectClass=inetOrgPerson)"
), * ),
), * ),
);*/ * );
*/
public $authServers = array (); public $authServers = array ();
/** The application Name displayed on authentication page */ /** The application Name displayed on authentication page */
@@ -58,6 +64,9 @@ class authentication
/** The class and method to use to log the errors */ /** The class and method to use to log the errors */
public $loggingFunc; public $loggingFunc;
/** The constructor
* @param object $route The route object
*/
public function __construct ($route) public function __construct ($route)
{ {
$this->route = $route; $this->route = $route;
@@ -69,7 +78,8 @@ class authentication
return $this->email; return $this->email;
}*/ }*/
/** Disconnect the user */ /** Disconnect the user
*/
public function logout () public function logout ()
{ {
if ($this->debug) echo "<pre>LOGOUT\n"; if ($this->debug) echo "<pre>LOGOUT\n";
@@ -88,7 +98,10 @@ class authentication
$this->route->redirect ("/authentication", ""); $this->route->redirect ("/authentication", "");
} }
/** Display the login page */ /** Display the login page
* @param string|null $url The url to be redirected after a valid
* authentication
*/
public function pageHTML ($url = "") public function pageHTML ($url = "")
{ {
// If the user is already connected, redirect to the main page of the site // If the user is already connected, redirect to the main page of the site
@@ -108,7 +121,10 @@ class authentication
$alreadyAuth); $alreadyAuth);
} }
/** Check the authentication page */ /** Check the authentication page
* @param string|null $url The url to be redirected after a valid
* authentication
*/
public function verifAuthLoginPage ($url = "") public function verifAuthLoginPage ($url = "")
{ {
// rate-limit the connections // rate-limit the connections
@@ -176,7 +192,8 @@ class authentication
$this->route->redirect ("/$url", ""); $this->route->redirect ("/$url", "");
} }
/** Check all the REST API */ /** Check all the REST API
*/
public function verifAuthREST () public function verifAuthREST ()
{ {
if ($this->debug) if ($this->debug)
@@ -201,7 +218,8 @@ class authentication
return $res; return $res;
} }
/** Check all the others pages of the site */ /** Check all the others pages of the site
*/
public function verifAuthHTML () public function verifAuthHTML ()
{ {
if ($this->debug) if ($this->debug)
@@ -234,10 +252,13 @@ class authentication
} }
/** Do the real authentication process on all the providers defined in the /** Do the real authentication process on all the providers defined in the
properties of the class. * properties of the class.
@return an array containing the user data if the authentication is * @param string $email The email to check
correct, * @param string $password The password to check
an exception if noting is found */ * @return an array containing the user data if the authentication is
* correct,
* an exception if noting is found
*/
private function verifAuth ($email, $password) private function verifAuth ($email, $password)
{ {
if ($this->debug) if ($this->debug)
@@ -350,6 +371,8 @@ class authentication
/** The default method to display the error messages. /** The default method to display the error messages.
* Do not display the debug messages, and write the errors on screen * Do not display the debug messages, and write the errors on screen
* @param integer $priority The priority of the message
* @param string $message The message to log
*/ */
private function logging ($priority, $message) private function logging ($priority, $message)
{ {

View File

@@ -15,6 +15,7 @@ class authhtpasswd extends auth
/** The details to return if the user is authenticated */ /** The details to return if the user is authenticated */
private $details = null; private $details = null;
/** There is no real connection to htpasswd */
public function connect () public function connect ()
{ {
if (! file_exists ($this->htpasswdFile)) if (! file_exists ($this->htpasswdFile))

View File

@@ -6,12 +6,16 @@
/** Takes the email and the password of the user */ /** Takes the email and the password of the user */
class authparams class authparams
{ {
/** The email of the user when provided */
public $email = null; public $email = null;
/** The password of the user when provided */
public $password = null; public $password = null;
/** Parse the different authentication processes to found the email/password /** Parse the different authentication processes to found the email/password
of the user. * of the user.
If non is found, return "anonymous", "anonymous" */ * If non is found, return "anonymous", "anonymous"
* @param array|null $authprocesses The authentication process to use
*/
public function __construct ($authprocesses=array("session","post")) public function __construct ($authprocesses=array("session","post"))
{ {
if (php_sapi_name () === "cli") if (php_sapi_name () === "cli")

View File

@@ -21,8 +21,9 @@ class authsession extends auth
} }
/** Try to authenticate the email/password of the user /** Try to authenticate the email/password of the user
@param string $email Email to authenticate * @param string $email Email to authenticate
@param string $password Password to authenticate */ * @param string $password Password to authenticate
*/
public function authentication ($email, $password) public function authentication ($email, $password)
{ {
if (!isset ($_SESSION["domframework"]["auth"]["email"]) || if (!isset ($_SESSION["domframework"]["auth"]["email"]) ||
@@ -47,9 +48,10 @@ class authsession extends auth
} }
/** Method to change the password : unavailable in SESSION auth /** Method to change the password : unavailable in SESSION auth
@param string $oldpassword The old password (to check if the user have the * @param string $oldpassword The old password (to check if the user have the
rights to change the password) * rights to change the password)
@param string $newpassword The new password to be recorded */ * @param string $newpassword The new password to be recorded
*/
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
@@ -58,10 +60,11 @@ class authsession extends auth
} }
/** Method to overwrite the password (without oldpassword check) /** Method to overwrite the password (without oldpassword check)
Must be reserved to the administrators. For the users, use changepassword * Must be reserved to the administrators. For the users, use changepassword
method * method
@param string $email the user identifier to select * @param string $email the user identifier to select
@param string $newpassword The new password to be recorded */ * @param string $newpassword The new password to be recorded
*/
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new exception (dgettext("domframework", throw new exception (dgettext("domframework",
@@ -70,13 +73,22 @@ class authsession extends auth
} }
/** Save the data in session /** Save the data in session
@deprecated 0.23 */ * @param string $email The email to store in the session
* @param string $password The password to store in the session
* @param string $lastname The lastname to store in the session
* @param string $firstname The firstname to store in the session
* @deprecated 0.23 */
public function savedatas ($email, $password, $lastname, $firstname) public function savedatas ($email, $password, $lastname, $firstname)
{ {
return $this->savedata ($email, $password, $lastname, $firstname); return $this->savedata ($email, $password, $lastname, $firstname);
} }
/** Save the data in session */ /** Save the data in session
* @param string $email The email to store in the session
* @param string $password The password to store in the session
* @param string $lastname The lastname to store in the session
* @param string $firstname The firstname to store in the session
*/
public function savedata ($email, $password, $lastname, $firstname) public function savedata ($email, $password, $lastname, $firstname)
{ {
$_SESSION["domframework"]["auth"]["lastname"] = $lastname; $_SESSION["domframework"]["auth"]["lastname"] = $lastname;

View File

@@ -6,13 +6,19 @@
/** User authentication against Shibboleth */ /** User authentication against Shibboleth */
class authshibboleth extends auth class authshibboleth extends auth
{ {
/** The parameters returned by Shibboleth server */ /** The Lastname parameter returned by Shibboleth server */
public $lastnameParam = "sn"; public $lastnameParam = "sn";
/** The Firstname parameter returned by Shibboleth server */
public $firstnameParam = "givenName"; public $firstnameParam = "givenName";
/** The mail parameter returned by Shibboleth server */
public $mailParam = "mail"; public $mailParam = "mail";
/** The others parameters returned by Shibboleth server */
public $otherFields = array ("ou", "o"); public $otherFields = array ("ou", "o");
/** The optional URL use to authenticate the users */
public $urlAuthentificated = ""; public $urlAuthentificated = "";
/** The optional URL to disconnect the users */
public $urlLogout = ""; public $urlLogout = "";
/** The optional URL to change the user password */
public $urlPasswd = ""; public $urlPasswd = "";
/** No connection to shibboleth */ /** No connection to shibboleth */

View File

@@ -129,6 +129,8 @@ class language
} }
/** Return the language recorded in the Cookie. Check if this language is /** Return the language recorded in the Cookie. Check if this language is
* @param string $cookieName The cookie name
* @param string|null $repLocale The directory use to store the locale files
* allowed * allowed
* @return string The language allowed or FALSE * @return string The language allowed or FALSE
*/ */
@@ -156,6 +158,7 @@ class language
/** Return an array with all the languages available in the $repLocale dir /** Return an array with all the languages available in the $repLocale dir
* The languages are in the format 'en_US' without the codeset. * The languages are in the format 'en_US' without the codeset.
* @param string|null $repLocale The directory use to store the locale files
* Return FALSE if there is an error * Return FALSE if there is an error
*/ */
function languageTraductionsList ($repLocale = "./locale") function languageTraductionsList ($repLocale = "./locale")
@@ -357,8 +360,10 @@ class language
} }
/** Return the language subtag for the language /** Return the language subtag for the language
http://www.iana.org/assignments/language-subtag-registry/ * http://www.iana.org/assignments/language-subtag-registry/
language-subtag-registry*/ * language-subtag-registry
* @param string $languageCode The language code to convert
*/
public function languageSubTag ($languageCode) public function languageSubTag ($languageCode)
{ {
return str_replace ("_", "-", $languageCode); return str_replace ("_", "-", $languageCode);

View File

@@ -62,6 +62,12 @@ class logger
set_error_handler (array (&$this, "errorHandler")); set_error_handler (array (&$this, "errorHandler"));
} }
/** The error handler to log
* @param integer $errno The error number to use
* @param string $errstr The error message to save
* @param string $errfile The file which generate the error
* @param integer $errline The line where the error is generated
*/
public function errorHandler ($errno, $errstr, $errfile, $errline) public function errorHandler ($errno, $errstr, $errfile, $errline)
{ {
if (!(error_reporting() & $errno)) if (!(error_reporting() & $errno))

View File

@@ -92,7 +92,17 @@ class routeSQL
/** The Datas are protected in read-only */ /** The Datas are protected in read-only */
private $readwriteAllowed = true; private $readwriteAllowed = true;
/** Connect to the database */ /** Connect to the database
* @param string $model_file The model file containing the database
* description
* @param string $model_class The model class included in the model file
* @param string $url_prefix The prefix to be used in the URL. Should be the
* end of $model_file
* @param string $dsn The DSN to connect to the database
* @param string $username The username to connect to the database
* @param string $password The password to connect to the database
* @param array|null $driver_options The PDO driver options
*/
public function __construct ($model_file, $model_class, $url_prefix, $dsn, public function __construct ($model_file, $model_class, $url_prefix, $dsn,
$username = null, $password = null, $driver_options = null) $username = null, $password = null, $driver_options = null)
{ {
@@ -156,9 +166,14 @@ class routeSQL
} }
/** Display a paginator /** Display a paginator
$nbentries is the total number of elements * $nbentries is the total number of elements
num is the number of elements displayed by page * num is the number of elements displayed by page
page is the page to display */ * page is the page to display
* @param integer $nbentries The number of entries to display
* @param integer $page The page number to display
* @param integer $num ???
* @param string $search The search query
*/
private function paginatorArea ($nbentries, $page, $num, $search) private function paginatorArea ($nbentries, $page, $num, $search)
{ {
// The maximum of links available in the paginator // The maximum of links available in the paginator
@@ -217,7 +232,12 @@ $content .= "</li>\n";
} }
/** Display the actions buttons outside of the table (actually, juste the /** Display the actions buttons outside of the table (actually, juste the
'Add new entry' button */ * 'Add new entry' button
* @param integer $nbentries The number of entries
* @param integer $page The page number
* @param integer $num ???
* @param string $search The search query
*/
private function addNewArea ($nbentries, $page, $num, $search) private function addNewArea ($nbentries, $page, $num, $search)
{ {
$content = ""; $content = "";
@@ -232,7 +252,12 @@ $content .= "</li>\n";
return $content; return $content;
} }
/** Display the select list to choose the number of displayed entries */ /** Display the select list to choose the number of displayed entries
* @param integer $nbentries The number of entries
* @param integer $page The page number
* @param integer $num ???
* @param string $search The search query
*/
private function numberEntryByDisplayArea ($nbentries, $page, $num, $search) private function numberEntryByDisplayArea ($nbentries, $page, $num, $search)
{ {
$route = new route (); $route = new route ();
@@ -256,7 +281,12 @@ $content .= "</li>\n";
return $content; return $content;
} }
/** Display the search area */ /** Display the search area
* @param integer $nbentries The number of entries
* @param integer $page The page number
* @param integer $num ???
* @param string $search The search query
*/
private function searchArea ($nbentries, $page, $num, $search) private function searchArea ($nbentries, $page, $num, $search)
{ {
$route = new route (); $route = new route ();
@@ -272,7 +302,12 @@ $content .= "</li>\n";
return $content; return $content;
} }
/** Display the information */ /** Display the information
* @param integer $nbentries The number of entries
* @param integer $page The page number
* @param integer $num ???
* @param string $search The search query
*/
private function informationArea ($nbentries, $page, $num, $search) private function informationArea ($nbentries, $page, $num, $search)
{ {
$content = ""; $content = "";
@@ -1757,7 +1792,10 @@ $content .= "</li>\n";
} }
/** Authorization : Return TRUE if the user right allow to see the data /** Authorization : Return TRUE if the user right allow to see the data
Return FALSE else */ * Return FALSE else
* @param array $auth The auth to authenticate
* @param integer|null $id The id to examine
*/
public function accessright ($auth, $id=null) public function accessright ($auth, $id=null)
{ {
// echo "accessright=".var_export ($id, TRUE)." for ". // echo "accessright=".var_export ($id, TRUE)." for ".
@@ -1775,7 +1813,10 @@ $content .= "</li>\n";
} }
/** Authorization : Return TRUE if the user right allow to edit the data /** Authorization : Return TRUE if the user right allow to edit the data
Return FALSE else */ * Return FALSE else
* @param array $auth The auth to authenticate
* @param integer|null $id The id to examine
*/
public function editright ($auth, $id=null) public function editright ($auth, $id=null)
{ {
// echo "editright=".var_export ($id, TRUE)." for ". // echo "editright=".var_export ($id, TRUE)." for ".
@@ -1792,7 +1833,10 @@ $content .= "</li>\n";
} }
/** Authorization : Return TRUE if the $id is in READONLY for the user or /** Authorization : Return TRUE if the $id is in READONLY for the user or
FALSE if the user have the RW rights */ * FALSE if the user have the RW rights
* @param array $auth The auth to authenticate
* @param integer|null $id The id to examine
*/
public function readonly ($auth, $id=null) public function readonly ($auth, $id=null)
{ {
// echo "readonly=".var_export ($id, TRUE)." for ". // echo "readonly=".var_export ($id, TRUE)." for ".
@@ -1809,8 +1853,10 @@ $content .= "</li>\n";
} }
/** Return the data of the row if the $id exists in the primary key of the /** Return the data of the row if the $id exists in the primary key of the
table * table
Return FALSE in the other cases */ * Return FALSE in the other cases
* @param integer $id The id to examine
*/
public function keyexists ($id) public function keyexists ($id)
{ {
$data = $this->objectDB->read (array (array ($this->objectDB->primary, $data = $this->objectDB->read (array (array ($this->objectDB->primary,
@@ -1820,7 +1866,9 @@ $content .= "</li>\n";
return FALSE; return FALSE;
} }
/** Display the data in HTML with the view class/method if they are defined */ /** Display the data in HTML with the view class/method if they are defined
* @param array $data The data to display
*/
private function rendererhtml ($data) private function rendererhtml ($data)
{ {
require_once ("domframework/outputhtml.php"); require_once ("domframework/outputhtml.php");
@@ -1849,6 +1897,11 @@ $content .= "</li>\n";
exit; exit;
} }
/** Return the result converted by JSON/XML, defined in REST
* @param string $extension The display method
* @param array $data The data to return
* @param integer $getCode The HTTP code to return (200 OK by default)
*/
private function renderrest ($extension, $data, $getCode=200) private function renderrest ($extension, $data, $getCode=200)
{ {
require_once ("domframework/output$extension.php"); require_once ("domframework/output$extension.php");