pwqual_plugin.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
  2. /*
  3. * Copyright (C) 2010 by the Massachusetts Institute of Technology.
  4. * All rights reserved.
  5. *
  6. * Export of this software from the United States of America may
  7. * require a specific license from the United States Government.
  8. * It is the responsibility of any person or organization contemplating
  9. * export to obtain such a license before exporting.
  10. *
  11. * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  12. * distribute this software and its documentation for any purpose and
  13. * without fee is hereby granted, provided that the above copyright
  14. * notice appear in all copies and that both that copyright notice and
  15. * this permission notice appear in supporting documentation, and that
  16. * the name of M.I.T. not be used in advertising or publicity pertaining
  17. * to distribution of the software without specific, written prior
  18. * permission. Furthermore if you modify this software you must label
  19. * your software as modified software and not distribute it in such a
  20. * fashion that it might be confused with the original M.I.T. software.
  21. * M.I.T. makes no representations about the suitability of
  22. * this software for any purpose. It is provided "as is" without express
  23. * or implied warranty.
  24. */
  25. /*
  26. * Declarations for password quality plugin module implementors.
  27. *
  28. * The password quality pluggable interface currently has only one supported
  29. * major version, which is 1. Major version 1 has a current minor version
  30. * number of 1.
  31. *
  32. * Password quality plugin modules should define a function named
  33. * pwqual_<modulename>_initvt, matching the signature:
  34. *
  35. * krb5_error_code
  36. * pwqual_modname_initvt(krb5_context context, int maj_ver, int min_ver,
  37. * krb5_plugin_vtable vtable);
  38. *
  39. * The initvt function should:
  40. *
  41. * - Check that the supplied maj_ver number is supported by the module, or
  42. * return KRB5_PLUGIN_VER_NOTSUPP if it is not.
  43. *
  44. * - Cast the vtable pointer as appropriate for maj_ver:
  45. * maj_ver == 1: Cast to krb5_pwqual_vtable
  46. *
  47. * - Initialize the methods of the vtable, stopping as appropriate for the
  48. * supplied min_ver. Optional methods may be left uninitialized.
  49. *
  50. * Memory for the vtable is allocated by the caller, not by the module.
  51. */
  52. #ifndef KRB5_PWQUAL_PLUGIN_H
  53. #define KRB5_PWQUAL_PLUGIN_H
  54. #include <krb5/krb5.h>
  55. #include <krb5/plugin.h>
  56. #include <kadm5/admin.h>
  57. /* An abstract type for password quality module data. */
  58. typedef struct krb5_pwqual_moddata_st *krb5_pwqual_moddata;
  59. /*** Method type declarations ***/
  60. /* Optional: Initialize module data. dictfile is the realm's configured
  61. * dictionary filename. */
  62. typedef krb5_error_code
  63. (*krb5_pwqual_open_fn)(krb5_context context, const char *dict_file,
  64. krb5_pwqual_moddata *data);
  65. /*
  66. * Mandatory: Check a password for the principal princ, which has an associated
  67. * password policy named policy_name (or no associated policy if policy_name is
  68. * NULL). The parameter languages, if not NULL, contains a null-terminated
  69. * list of client-specified language tags as defined in RFC 5646. The method
  70. * should return one of the following errors if the password fails quality
  71. * standards:
  72. *
  73. * - KADM5_PASS_Q_TOOSHORT: password should be longer
  74. * - KADM5_PASS_Q_CLASS: password must have more character classes
  75. * - KADM5_PASS_Q_DICT: password contains dictionary words
  76. * - KADM5_PASS_Q_GENERIC: unspecified quality failure
  77. *
  78. * The module should also set an extended error message with
  79. * krb5_set_error_message(). The message may be localized according to one of
  80. * the language tags in languages.
  81. */
  82. typedef krb5_error_code
  83. (*krb5_pwqual_check_fn)(krb5_context context, krb5_pwqual_moddata data,
  84. const char *password, const char *policy_name,
  85. krb5_principal princ, const char **languages);
  86. /* Optional: Release resources used by module data. */
  87. typedef void
  88. (*krb5_pwqual_close_fn)(krb5_context context, krb5_pwqual_moddata data);
  89. /*** vtable declarations **/
  90. /* Password quality plugin vtable for major version 1. */
  91. typedef struct krb5_pwqual_vtable_st {
  92. const char *name; /* Mandatory: name of module. */
  93. krb5_pwqual_open_fn open;
  94. krb5_pwqual_check_fn check;
  95. krb5_pwqual_close_fn close;
  96. /* Minor version 1 ends here. */
  97. } *krb5_pwqual_vtable;
  98. #endif /* KRB5_PWQUAL_PLUGIN_H */