25#ifndef ROUTER_HTTP_AUTH_BACKEND_INCLUDED
26#define ROUTER_HTTP_AUTH_BACKEND_INCLUDED
30#include <system_error>
34#include <rapidjson/document.h>
56 const std::string &authdata) = 0;
65 using stat_res = std::pair<std::error_code, struct stat>;
131 using iterator = std::map<key_type, value_type>::iterator;
141 std::error_code from_file(
const std::string &
filename);
149 std::error_code from_stream(std::istream &is);
154 void to_stream(std::ostream &os);
160 credentials_cache_.erase(username);
161 return credentials_.erase(username);
171 auto res = credentials_.insert({username, authdata});
173 auto elem_it = res.first;
175 elem_it->second = authdata;
183 return credentials_.find(username);
190 return credentials_.find(username);
219 std::error_code authenticate(
const key_type &username,
232 static std::string hash_password(
const std::string &
password);
233 std::error_code from_stream_(std::istream &is);
235 bool is_file_{
false};
check if a file was modified.
Definition: http_auth_backend.h:81
FileModified(const FileMeta &meta)
Definition: http_auth_backend.h:84
bool operator==(const FileModified &b) const
check if two FileModified's are equal.
Definition: http_auth_backend.cc:69
FileMeta meta_
Definition: http_auth_backend.h:92
hashed key store.
Definition: http_auth_backend.h:122
iterator begin() noexcept
begin iterator.
Definition: http_auth_backend.h:206
std::string cache_type
Definition: http_auth_backend.h:126
const_iterator begin() const noexcept
const begin iterator.
Definition: http_auth_backend.h:211
const_iterator end() const noexcept
const end iterator.
Definition: http_auth_backend.h:201
iterator find(const key_type &username)
find username in cache.
Definition: http_auth_backend.h:182
const_iterator find(const key_type &username) const
find username in cache.
Definition: http_auth_backend.h:189
std::map< key_type, value_type > credentials_
Definition: http_auth_backend.h:239
size_t erase(const key_type &username)
remove username from credential cache.
Definition: http_auth_backend.h:159
std::string key_type
Definition: http_auth_backend.h:124
std::string value_type
Definition: http_auth_backend.h:125
void set(const key_type &username, const value_type &authdata)
set username and password in cache.
Definition: http_auth_backend.h:170
std::map< key_type, value_type >::iterator iterator
iterator
Definition: http_auth_backend.h:131
std::map< key_type, cache_type > credentials_cache_
Definition: http_auth_backend.h:240
iterator end() noexcept
end iterator.
Definition: http_auth_backend.h:196
FileModified file_meta_
Definition: http_auth_backend.h:237
std::string filename_
Definition: http_auth_backend.h:236
std::map< key_type, value_type >::const_iterator const_iterator
const iterator
Definition: http_auth_backend.h:136
Base class of all AuthBackends.
Definition: http_auth_backend.h:44
HttpAuthBackend(HttpAuthBackend &&)=default
HttpAuthBackend & operator=(const HttpAuthBackend &)=default
virtual ~HttpAuthBackend()=0
destructor.
HttpAuthBackend(const HttpAuthBackend &)=default
virtual std::error_code authenticate(const std::string &username, const std::string &authdata)=0
authentication username with authdata against backend.
HttpAuthBackend & operator=(HttpAuthBackend &&)=default
HttpAuthBackend()=default
#define HTTP_AUTH_BACKEND_LIB_EXPORT
Definition: http_auth_backend_lib_export.h:15
Define rapidjson::SizeType to be std::size_t.
static char * password
Definition: mysql_secure_installation.cc:57
int key_type
Definition: http_request.h:49
uint16_t value_type
Definition: vt100.h:183
const char * filename
Definition: pfs_example_component_population.cc:66