Kea 2.7.5
basic_auth.h
Go to the documentation of this file.
1// Copyright (C) 2020-2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef BASIC_HTTP_AUTH_H
8#define BASIC_HTTP_AUTH_H
9
10#include <http/header_context.h>
12#include <boost/shared_ptr.hpp>
13#include <unordered_set>
14
15namespace isc {
16namespace http {
17
22public:
23
29 BasicHttpAuth(const std::string& user, const std::string& password);
30
35 BasicHttpAuth(const std::string& secret);
36
38 const std::string& getSecret() const {
39 return (secret_);
40 }
41
43 const std::string& getCredential() const {
44 return (credential_);
45 }
46
47private:
48
50 void buildSecret();
51
53 void buildCredential();
54
56 std::string user_;
57
59 std::string password_;
60
62 std::string secret_;
63
66 std::string credential_;
67};
68
70typedef boost::shared_ptr<BasicHttpAuth> BasicHttpAuthPtr;
71
74
78 explicit BasicAuthHttpHeaderContext(const BasicHttpAuth& basic_auth)
79 : HttpHeaderContext("Authorization",
80 "Basic " + basic_auth.getCredential()) {
81 }
82};
83
84} // end of namespace isc::http
85} // end of namespace isc
86
87#endif // endif BASIC_HTTP_AUTH_H
Represents a basic HTTP authentication.
Definition basic_auth.h:21
const std::string & getCredential() const
Returns the credential (base64 of the UTF-8 secret).
Definition basic_auth.h:43
BasicHttpAuth(const std::string &user, const std::string &password)
Constructor.
Definition basic_auth.cc:19
const std::string & getSecret() const
Returns the secret.
Definition basic_auth.h:38
boost::shared_ptr< BasicHttpAuth > BasicHttpAuthPtr
Type of pointers to basic HTTP authentication objects.
Definition basic_auth.h:70
Defines the logger used by the top-level component of kea-lfc.
Represents basic HTTP authentication header.
Definition basic_auth.h:73
BasicAuthHttpHeaderContext(const BasicHttpAuth &basic_auth)
Constructor.
Definition basic_auth.h:78