Kea 3.1.1
gss_tsig_impl.h
Go to the documentation of this file.
1// Copyright (C) 2021-2025 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 GSS_TSIG_IMPL_H
8#define GSS_TSIG_IMPL_H
9
11#include <gss_tsig_cfg.h>
12#include <hooks/hooks.h>
13#include <managed_key.h>
14
15#include <boost/multi_index/composite_key.hpp>
16#include <boost/multi_index/ordered_index.hpp>
17#include <chrono>
18#include <memory>
19
20namespace isc {
21namespace gss_tsig {
22
25
28
30typedef boost::multi_index_container<
31 // It holds pointers to GSS-TSIG key objects.
33 boost::multi_index::indexed_by<
34 // First index is the by DNS name.
35 boost::multi_index::hashed_unique<
36 boost::multi_index::tag<GssTsigKeyNameTag>,
37 boost::multi_index::const_mem_fun<ManagedKey, std::string,
39 >,
40
41 // Second index is by DNS server (parent) ID with the inception
42 // date to sort search results.
43 boost::multi_index::ordered_non_unique<
44 boost::multi_index::tag<GssTsigKeyServerTag>,
45 boost::multi_index::composite_key<
47 // The DNS server (parent) ID.
48 boost::multi_index::const_mem_fun<ManagedKey, std::string,
50 // The inception date.
51 boost::multi_index::const_mem_fun<GssTsigKey,
52 std::chrono::system_clock::time_point,
54 >
55 >
56 >
58
64public:
67
69 virtual ~GssTsigImpl();
70
76
81
88
93 io_service_ = io_service;
94 }
95
100 DnsServerPtr getServer(const std::string& id) const;
101
106 void start();
107
111 void stop();
112
117 void processAllServersKeys(bool rekey = false);
118
123 void processServerKeys(DnsServerPtr server, bool rekey = false);
124
129 void createKey(DnsServerPtr server,
130 std::chrono::time_point<std::chrono::system_clock> now);
131
140 ManagedKeyPtr findKey(const d2::DnsServerInfoPtr& server_info,
141 bool& useGssTsig, bool& fallback);
142
147 ManagedKeyPtr findKey(const std::string& name) const;
148
152 void purgeKeys();
153
157 void getHandler(isc::hooks::CalloutHandle& handle) const;
158
162 void getAllHandler(isc::hooks::CalloutHandle& handle) const;
163
167 void listHandler(isc::hooks::CalloutHandle& handle) const;
168
172 void keyGetHandler(isc::hooks::CalloutHandle& handle) const;
173
178
183
188
193
198
203
208
209protected:
212
215
218
220 std::unique_ptr<std::string> krb5_client_ktname_prev_;
221
223 std::unique_ptr<std::string> krb5ccname_prev_;
224
227};
228
230typedef std::unique_ptr<GssTsigImpl> GssTsigImplPtr;
231
232} // end of namespace isc::gss_tsig
233} // end of namespace isc
234
235#endif // GSS_TSIG_IMPL_H
GSS-TSIG hook configuration.
isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
void rekeyAllHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-rekey-all command handler.
std::unique_ptr< std::string > krb5_client_ktname_prev_
The previous value of client key table environment variable.
isc::asiolink::IOServicePtr io_service_
The hook I/O service.
void stop()
Stop method.
void purgeAllHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-purge-all command handler.
void finishConfigure(isc::d2::D2CfgContextPtr d2_config)
Finish configure.
GssTsigCfg cfg_
GSS-TSIG hook configuration.
void commandProcessed(isc::hooks::CalloutHandle &handle)
The command_processed handler.
void start()
Start method.
void keyExpireHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-key-expire command handler.
void purgeHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-purge command handler.
void rekeyHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-rekey command handler.
void getAllHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-get-all command handler.
void configure(isc::data::ConstElementPtr config)
Configure.
void keyDelHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-key-del command handler.
DnsServerPtr getServer(const std::string &id) const
Get the DNS server from its ID.
void processAllServersKeys(bool rekey=false)
Process GSS-TSIG keys for all servers.
ManagedKeyList keys_
Map of GSS-TSIG keys by name.
void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
ManagedKeyPtr findKey(const d2::DnsServerInfoPtr &server_info, bool &useGssTsig, bool &fallback)
Find a GSS-TSIG key by server info.
void purgeKeys()
Purge very old GSS-TSIG keys.
void processServerKeys(DnsServerPtr server, bool rekey=false)
Process GSS-TSIG keys for a specific server.
std::unique_ptr< std::string > krb5ccname_prev_
The previous value of credential cache environment variable.
void keyGetHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-key-get command handler.
isc::asiolink::IntervalTimerPtr purge_timer_
The purge periodic timer.
virtual ~GssTsigImpl()
Destructor.
void listHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-list command handler.
void getHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-get command handler.
void createKey(DnsServerPtr server, std::chrono::time_point< std::chrono::system_clock > now)
Create new GSS-TSIG key.
GSS-TSIG extension of the D2 TSIG key class.
std::chrono::system_clock::time_point getInception() const
Get the key inception.
Managed GSS-TSIG key.
Definition managed_key.h:24
std::string getKeyNameStr() const
Get the key name as a string.
Definition managed_key.h:53
std::string getParentID() const
Get the DNS server (parent) ID.
Definition managed_key.h:60
Per-packet callout handle.
int rekey(CalloutHandle &handle)
The gss-tsig-rekey command.
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition d2_config.h:554
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
Definition d2_cfg_mgr.h:26
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::multi_index_container< ManagedKeyPtr, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag< GssTsigKeyNameTag >, boost::multi_index::const_mem_fun< ManagedKey, std::string, &ManagedKey::getKeyNameStr > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< GssTsigKeyServerTag >, boost::multi_index::composite_key< ManagedKey, boost::multi_index::const_mem_fun< ManagedKey, std::string, &ManagedKey::getParentID >, boost::multi_index::const_mem_fun< GssTsigKey, std::chrono::system_clock::time_point, &GssTsigKey::getInception > > > > > ManagedKeyList
A multi index container holding GSS-TSIG keys.
std::unique_ptr< GssTsigImpl > GssTsigImplPtr
Type of pointer to a GSS-TSIG hook configuration.
boost::shared_ptr< DnsServer > DnsServerPtr
A pointer to a DNS server.
boost::shared_ptr< ManagedKey > ManagedKeyPtr
Type of pointer to a Managed GSS-TSIG key.
Defines the logger used by the top-level component of kea-lfc.
Tag for the name index for searching GSS-TSIG key.
Tag for the server ID index for searching GSS-TSIG key.