23 #include "user_verifier.h"
25 #include <core/exception.h>
26 #include <config/config.h>
27 #include <logging/logger.h>
36 #define HASH_REGEX "^(\\$([[:alnum:]]+)\\$([a-zA-Z0-9/.]+)\\$)[a-zA-Z0-9/.]+$"
51 : config(config), logger(logger)
54 if ((regerr = regcomp(&__hash_regex, HASH_REGEX, REG_EXTENDED)) != 0) {
56 regerror(regerr, &__hash_regex, errtmp,
sizeof(errtmp));
57 regfree(&__hash_regex);
58 throw Exception(
"Failed to compile hash regex: %s", errtmp);
66 regfree(&__hash_regex);
74 std::string userpath = std::string(
"/webview/users/") + user;
75 std::string confpass = config->
get_string(userpath.c_str());
78 if (regexec(&__hash_regex, confpass.c_str(), 4, m, 0) == REG_NOMATCH) {
82 return (confpass == password);
89 char *crypted = crypt_r(password, confpass.c_str(), &cd);
91 char *crypted = crypt(password, confpass.c_str());
94 if (confpass == crypted) {
virtual std::string get_string(const char *path)
Get value from configuration which is of type string.
Fawkes library namespace.
virtual ~WebviewUserVerifier()
Destructor.
virtual bool verify_user(const char *user, const char *password)
Verify a user.
Base class for exceptions in Fawkes.
Interface for configuration handling.
WebviewUserVerifier(fawkes::Configuration *config, fawkes::Logger *logger)
Constructor.