auth.hpp
1 #ifndef XXHR_AUTH_H
2 #define XXHR_AUTH_H
3 
4 #include <string>
5 
6 #include "defines.hpp"
7 
8 namespace xxhr {
9 
17  public:
18 
20  template <typename UserType, typename PassType>
21  Authentication(UserType&& username, PassType&& password)
22  : username_{XXHR_FWD(username)}, password_{XXHR_FWD(password)},
23  auth_string_{username_ + ":" + password_} {}
24 
25  const char* GetAuthString() const noexcept { return auth_string_.data(); }
26 
28  std::string username() const { return username_; }
30  std::string password() const { return password_; }
31 
32  private:
33  std::string username_;
34  std::string password_;
35  std::string auth_string_;
36 };
37 
38 } // namespace xxhr
39 
40 #endif
xxhr::Authentication::Authentication
Authentication(UserType &&username, PassType &&password)
Specify username and password for basic auth.
Definition: auth.hpp:21
xxhr::Authentication
Some Web APIs requires authenticating via HTTP Basic auth ( i.e. base64 encoded user and password aut...
Definition: auth.hpp:16
xxhr
main library namespace
Definition: api.hpp:20