service_mysql_password_policy.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program 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 General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. #ifndef MYSQL_SERVICE_MYSQL_PLUGIN_AUTH_INCLUDED
  19. #define MYSQL_SERVICE_MYSQL_PLUGIN_AUTH_INCLUDED
  20. /**
  21. @file include/mysql/service_mysql_plugin_auth.h
  22. This service provides functions to validatete password, check for strength
  23. of password based on common policy.
  24. SYNOPSIS
  25. my_validate_password_policy() - function to validate password
  26. based on defined policy
  27. const char* buffer holding the password value
  28. unsigned int buffer length
  29. my_calculate_password_strength() - function to calculate strength
  30. of the password based on the policies defined.
  31. const char* buffer holding the password value
  32. unsigned int buffer length
  33. Both the service function returns 0 on SUCCESS and 1 incase input password does not
  34. match against the policy rules defined.
  35. */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. extern struct mysql_password_policy_service_st {
  40. int (*my_validate_password_policy_func)(const char *, unsigned int);
  41. int (*my_calculate_password_strength_func)(const char *, unsigned int);
  42. } *mysql_password_policy_service;
  43. #ifdef MYSQL_DYNAMIC_PLUGIN
  44. #define my_validate_password_policy(buffer, length) \
  45. mysql_password_policy_service->my_validate_password_policy_func(buffer, length)
  46. #define my_calculate_password_strength(buffer, length) \
  47. mysql_password_policy_service->my_calculate_password_strength_func(buffer, length)
  48. #else
  49. int my_validate_password_policy(const char *, unsigned int);
  50. int my_calculate_password_strength(const char *, unsigned int);
  51. #endif
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif