model.authent-external.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Authent External
  18. * User authentication Module, for authentication outside of the iTop application
  19. * for example using a .htaccess file. The web server is in charge of authentifying the users
  20. * and providing the name (= 'login') of the authentified user in the $_SERVER['REMOTE_USER']
  21. * variable that is passed to PHP. iTop will not make any attempt to authentify such users.
  22. * Similarly once inside iTop, there is no way for the users to change their password or
  23. * log off from the iTop application, this has to be handled outside of iTop.
  24. *
  25. * @author Erwan Taloc <erwan.taloc@combodo.com>
  26. * @author Romain Quetiez <romain.quetiez@combodo.com>
  27. * @author Denis Flaven <denis.flaven@combodo.com>
  28. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  29. */
  30. class UserExternal extends User
  31. {
  32. public static function Init()
  33. {
  34. $aParams = array
  35. (
  36. "category" => "addon/authentication",
  37. "key_type" => "autoincrement",
  38. "name_attcode" => "login",
  39. "state_attcode" => "",
  40. "reconc_keys" => array('login'),
  41. "db_table" => "",
  42. "db_key_field" => "id",
  43. "db_finalclass_field" => "",
  44. "display_template" => "",
  45. );
  46. MetaModel::Init_Params($aParams);
  47. MetaModel::Init_InheritAttributes();
  48. // Display lists
  49. MetaModel::Init_SetZListItems('details', array('contactid', 'first_name', 'email', 'login', 'language', 'profile_list', 'allowed_org_list')); // Attributes to be displayed for the complete details
  50. MetaModel::Init_SetZListItems('list', array('first_name', 'last_name', 'login')); // Attributes to be displayed for a list
  51. // Search criteria
  52. MetaModel::Init_SetZListItems('standard_search', array('login', 'contactid')); // Criteria of the std search form
  53. MetaModel::Init_SetZListItems('advanced_search', array('login', 'contactid')); // Criteria of the advanced search form
  54. }
  55. /**
  56. * Check the user's password... always return true. Actually the password
  57. * is not even passed to this function, we trust the web server for authentifiying
  58. * the users
  59. */
  60. public function CheckCredentials($sPassword)
  61. {
  62. // External authentication: for iTop it's always Ok
  63. return true;
  64. }
  65. public function TrustWebServerContext()
  66. {
  67. return true;
  68. }
  69. public function CanChangePassword()
  70. {
  71. // External authentication: iTop has no way to change a user's password
  72. return false;
  73. }
  74. public function CanLogOff()
  75. {
  76. // External authentication: iTop has no way to force a log off
  77. return false;
  78. }
  79. public function ChangePassword($sOldPassword, $sNewPassword)
  80. {
  81. return false;
  82. }
  83. }
  84. ?>