model.authent-external.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. // Copyright (C) 2010-2012 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. /**
  19. * Authent External
  20. * User authentication Module, for authentication outside of the iTop application
  21. * for example using a .htaccess file. The web server is in charge of authentifying the users
  22. * and providing the name (= 'login') of the authentified user in the $_SERVER['REMOTE_USER']
  23. * variable that is passed to PHP. iTop will not make any attempt to authentify such users.
  24. * Similarly once inside iTop, there is no way for the users to change their password or
  25. * log off from the iTop application, this has to be handled outside of iTop.
  26. *
  27. * @copyright Copyright (C) 2010-2012 Combodo SARL
  28. * @license http://opensource.org/licenses/AGPL-3.0
  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', 'status', 'profile_list', 'allowed_org_list')); // Attributes to be displayed for the complete details
  50. MetaModel::Init_SetZListItems('list', array('first_name', 'last_name', 'login', 'status')); // Attributes to be displayed for a list
  51. // Search criteria
  52. MetaModel::Init_SetZListItems('standard_search', array('login', 'contactid', 'status')); // 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 ChangePassword($sOldPassword, $sNewPassword)
  75. {
  76. return false;
  77. }
  78. }
  79. ?>