c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef AUTH_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define AUTH_H
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen#include "auth-settings.h"
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen
432e34050a431634595b2b4f31597b62ffbddd39Timo Sirainen#define PASSWORD_HIDDEN_STR "<hidden>"
432e34050a431634595b2b4f31597b62ffbddd39Timo Sirainen
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainenenum auth_passdb_skip {
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen AUTH_PASSDB_SKIP_NEVER,
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen AUTH_PASSDB_SKIP_AUTHENTICATED,
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen AUTH_PASSDB_SKIP_UNAUTHENTICATED
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen};
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainenenum auth_userdb_skip {
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_USERDB_SKIP_NEVER,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_USERDB_SKIP_FOUND,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_USERDB_SKIP_NOTFOUND
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen};
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainenenum auth_db_rule {
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_DB_RULE_RETURN,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_DB_RULE_RETURN_OK,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_DB_RULE_RETURN_FAIL,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_DB_RULE_CONTINUE,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_DB_RULE_CONTINUE_OK,
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen AUTH_DB_RULE_CONTINUE_FAIL
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen};
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstruct auth_passdb {
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen struct auth_passdb *next;
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen
3cf67672fdc87583cb23ce088c95bb5dee60e74dTimo Sirainen const struct auth_passdb_settings *set;
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen struct passdb_module *passdb;
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen
74674a53a72dab535c61f455b2246ef2797844eaTimo Sirainen /* The caching key for this passdb, or NULL if caching isn't wanted. */
74674a53a72dab535c61f455b2246ef2797844eaTimo Sirainen const char *cache_key;
74674a53a72dab535c61f455b2246ef2797844eaTimo Sirainen
2d8f66596f445dd8b399b7032c3f0e9202015b63Timo Sirainen struct passdb_template *default_fields_tmpl;
2d8f66596f445dd8b399b7032c3f0e9202015b63Timo Sirainen struct passdb_template *override_fields_tmpl;
2d8f66596f445dd8b399b7032c3f0e9202015b63Timo Sirainen
559f278a4c54d9fa7e0f2e96ebceda30562f9009Timo Sirainen enum auth_passdb_skip skip;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_db_rule result_success;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_db_rule result_failure;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_db_rule result_internalfail;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen};
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstruct auth_userdb {
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen struct auth_userdb *next;
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen
3cf67672fdc87583cb23ce088c95bb5dee60e74dTimo Sirainen const struct auth_userdb_settings *set;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen struct userdb_module *userdb;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen
74674a53a72dab535c61f455b2246ef2797844eaTimo Sirainen /* The caching key for this userdb, or NULL if caching isn't wanted. */
74674a53a72dab535c61f455b2246ef2797844eaTimo Sirainen const char *cache_key;
74674a53a72dab535c61f455b2246ef2797844eaTimo Sirainen
2d8f66596f445dd8b399b7032c3f0e9202015b63Timo Sirainen struct userdb_template *default_fields_tmpl;
2d8f66596f445dd8b399b7032c3f0e9202015b63Timo Sirainen struct userdb_template *override_fields_tmpl;
2d8f66596f445dd8b399b7032c3f0e9202015b63Timo Sirainen
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_userdb_skip skip;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_db_rule result_success;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_db_rule result_failure;
cd75c360f244c96b9ee10e01ee3a66fad13183c8Timo Sirainen enum auth_db_rule result_internalfail;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen};
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstruct auth {
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen pool_t pool;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen const char *service;
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen const struct auth_settings *set;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen const struct mechanisms_register *reg;
8eb94c5190ba09bb6f6f068eec7bf96750f08d1dTimo Sirainen struct auth_passdb *masterdbs;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen struct auth_passdb *passdbs;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen struct auth_userdb *userdbs;
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen};
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenextern struct auth_penalty *auth_penalty;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenstruct auth *auth_find_service(const char *name);
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainenstruct auth *auth_default_service(void);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
5d60e31c7b701b606067a20bc88dcc8a6de7bbd6Timo Sirainenvoid auths_preinit(const struct auth_settings *set, pool_t pool,
5d60e31c7b701b606067a20bc88dcc8a6de7bbd6Timo Sirainen const struct mechanisms_register *reg,
5d60e31c7b701b606067a20bc88dcc8a6de7bbd6Timo Sirainen const char *const *services);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenvoid auths_init(void);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenvoid auths_deinit(void);
9d75363d3fbabc2fbc2d80f06672e3ed8965804aTimo Sirainenvoid auths_free(void);
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainen
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen#endif