API 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ******************************
  2. * Change Password plugin API *
  3. ******************************
  4. Document should explain how to create change_password plugin backends and
  5. provide details about plugin structure.
  6. Plugin uses standard SquirrelMail plugin architecture and implements backends
  7. with two hooks.
  8. change_password_init hook
  9. -------------------------
  10. change_password_init hook is used to execute some code before displaying
  11. change password form. Plugin can use this hook to check if install has all
  12. required components, or to check if backend is configured correctly, or
  13. display some messages to end user. Maybe some background information about
  14. password security and how to choose good password. If backend detects some
  15. configuration errors that make backend unusable, it can stop execution of the
  16. script with PHP exit() call.
  17. change_password_dochange hook
  18. -----------------------------
  19. change_password_dochange hook is used when user submits old and new passwords.
  20. Plugin checks if old password matches current session password and checks new
  21. password satisfies requirements set in plugin's configuration. All data is
  22. provided in array submitted via hook. 'username' key contains user's login
  23. name, 'curpw' contains current session password, 'newpw' contains new password.
  24. Function that is attached to plugin should return empty array or array filled
  25. with error messages. If array is empty - plugin assumes that password was
  26. changed and updates current session password.
  27. common strings
  28. --------------
  29. Backends can use constants for some error messages. CPW_CURRENT_NOMATCH
  30. constant sets 'Your current password is not correct.' error. CPW_INVALID_PW
  31. constant sets 'Your new password contains invalid characters.' error.
  32. Recommendations
  33. ---------------
  34. Backend should check, if current password matches stored password.
  35. Internal plugin functions only check if password matches the one that
  36. was used to login into SquirrelMail. Password is validated against IMAP
  37. server and not against used backend.
  38. Backend should store only default configuration variables that don't
  39. have any information specific to developer's server or these variables
  40. should be set to sane default values.
  41. Backend's configuration should be controlled with configuration overrides
  42. that are set config.php. It is recommended to use array with
  43. configuration overrides and make sure that array is set to empty value
  44. before loading plugin's configuration file.
  45. Backend should not use generic function names. It is recommended to use
  46. 'cpw_' prefix.
  47. If backend must load other SquirrelMail functions, it must use SM_PATH
  48. constant in include_once() calls and make sure that SM_PATH is defined
  49. in any case when backend file is loaded. In most cases constant is
  50. already defined, but some unusual use of php files might cause php
  51. warnings, if constant is used inside backend functions and not defined
  52. in backend file.
  53. Overrides used by backend and backend requirements must be documented
  54. in README file.