zmqpp 4.1.2
C++ bindings for 0mq (libzmq)
Loading...
Searching...
No Matches
auth.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * This file is part of zmqpp.
7 * Copyright (c) 2011-2015 Contributors as noted in the AUTHORS file.
8 */
9
17#ifndef ZMQPP_AUTH_HPP_
18#define ZMQPP_AUTH_HPP_
19
20#include <string>
21#include <memory>
22#include <unordered_set>
23#include <unordered_map>
24
25#include "actor.hpp"
26#include "poller.hpp"
27#include "socket.hpp"
28#include "context.hpp"
29#include "zap_request.hpp"
30
31
32// Authentication is something from zmq 4
33#if (ZMQ_VERSION_MAJOR > 3)
34
35namespace zmqpp
36{
37
46class auth
47{
48public:
55 auth(context& ctx);
56
61 ~auth();
62
71 void allow(const std::string &address);
72
80 void deny(const std::string &address);
81
85 void configure_domain(const std::string &domain);
86
92 void configure_plain(const std::string &username, const std::string &password);
93
100 void configure_curve(const std::string &client_public_key);
101
108 void configure_gssapi();
109
114 void set_verbose(bool verbose);
115
116private:
121 void handle_command(socket& pipe);
122
128 bool authenticate_plain(zap_request& request, std::string &user_id);
129
135 bool authenticate_curve(zap_request& request, std::string &user_id);
136
141 bool authenticate_gssapi(zap_request& request);
142
147 void authenticate(socket& sock);
148
149 std::shared_ptr<actor> authenticator; // ZAP authentication actor
150 poller auth_poller; // Socket poller
151 std::unordered_set<std::string> whitelist; // Whitelisted addresses
152 std::unordered_set<std::string> blacklist; // Blacklisted addresses
153 std::unordered_map<std::string, std::string> passwords; // PLAIN passwords, if loaded
154 std::unordered_set<std::string> client_keys; // Client public keys
155 std::string domain; // ZAP domain
156 bool curve_allow_any; // CURVE allows arbitrary clients
157 bool terminated; // Did caller ask us to quit?
158 bool verbose; // Verbose logging enabled?
159
160# if defined(ZMQPP_NO_CONSTEXPR)
161 static const char * const zap_endpoint_;
162# else
163 constexpr static const char * const zap_endpoint_ = "inproc://zeromq.zap.01";
164# endif
165
166 // No copy - private and not implemented
169};
170
171}
172
173#endif
174
175#endif /* ZMQPP_AUTH_HPP_ */
auth - authentication for ZeroMQ security mechanisms
Definition: auth.hpp:47
bool authenticate_gssapi(zap_request &request)
Handle a GSSAPI authentication request from libzmq core.
Definition: auth.cpp:299
auth(auth const &) ZMQPP_EXPLICITLY_DELETED
void configure_domain(const std::string &domain)
Configure a ZAP domain.
Definition: auth.cpp:95
std::string domain
Definition: auth.hpp:155
std::unordered_set< std::string > whitelist
Definition: auth.hpp:151
std::shared_ptr< actor > authenticator
Definition: auth.hpp:149
bool authenticate_curve(zap_request &request, std::string &user_id)
Handle a CURVE authentication request from libzmq core.
Definition: auth.cpp:273
auth & operator=(auth const &) NOEXCEPT ZMQPP_EXPLICITLY_DELETED
void configure_plain(const std::string &username, const std::string &password)
Configure PLAIN authentication.
Definition: auth.cpp:103
std::unordered_set< std::string > blacklist
Definition: auth.hpp:152
std::unordered_map< std::string, std::string > passwords
Definition: auth.hpp:153
void configure_curve(const std::string &client_public_key)
Configure CURVE authentication.
Definition: auth.cpp:117
void set_verbose(bool verbose)
Enable verbose tracing of commands and activity.
Definition: auth.cpp:142
bool curve_allow_any
Definition: auth.hpp:156
std::unordered_set< std::string > client_keys
Definition: auth.hpp:154
void allow(const std::string &address)
Allow (whitelist) a single IP address.
Definition: auth.cpp:81
void deny(const std::string &address)
Deny (blacklist) a single IP address.
Definition: auth.cpp:88
static constexpr const char *const zap_endpoint_
Definition: auth.hpp:163
bool verbose
Definition: auth.hpp:158
bool terminated
Definition: auth.hpp:157
void configure_gssapi()
Configure GSSAPI authentication.
Definition: auth.cpp:130
void handle_command(socket &pipe)
Handle an authentication command from calling application.
Definition: auth.cpp:155
poller auth_poller
Definition: auth.hpp:150
void authenticate(socket &sock)
Authentication.
Definition: auth.cpp:307
bool authenticate_plain(zap_request &request, std::string &user_id)
Handle a PLAIN authentication request from libzmq core.
Definition: auth.cpp:253
~auth()
Destructor.
Definition: auth.cpp:74
The context class represents internal zmq context and io threads.
Definition: context.hpp:47
Polling wrapper.
Definition: poller.hpp:37
The socket class represents the zmq sockets.
Definition: socket.hpp:76
A class for working with ZAP requests and replies.
Definition: zap_request.hpp:35
#define NOEXCEPT
Definition: compatibility.hpp:122
#define ZMQPP_EXPLICITLY_DELETED
Definition: compatibility.hpp:107
C++ wrapper around zmq.
Definition: actor.cpp:30