pvAccessCPP 7.1.8
Loading...
Searching...
No Matches
security.h
1
7#ifndef SECURITY_H
8#define SECURITY_H
9
76#ifdef epicsExportSharedSymbols
77# define securityEpicsExportSharedSymbols
78# undef epicsExportSharedSymbols
79#endif
80
81#include <string>
82#include <osiSock.h>
83#include <epicsMutex.h>
84
85#include <pv/status.h>
86#include <pv/pvData.h>
87#include <pv/sharedPtr.h>
88
89#ifdef securityEpicsExportSharedSymbols
90# define epicsExportSharedSymbols
91# undef securityEpicsExportSharedSymbols
92#endif
93
94#include <pv/pvaDefs.h>
95#include <pv/pvaConstants.h>
96#include <pv/serializationHelper.h>
97#include <pv/logger.h>
98
99#include <shareLib.h>
100
101namespace epics {
102namespace pvAccess {
103
119struct epicsShareClass PeerInfo {
120 POINTER_DEFINITIONS(PeerInfo);
121
122 static size_t num_instances;
123
124 std::string peer;
125 std::string transport;
126 std::string authority;
127 std::string realm;
128 std::string account;
129
131 pvData::PVStructure::const_shared_pointer aux;
132
136
138
139 // attributes for programatic consumption
140 bool local;
142
143 PeerInfo();
144 virtual ~PeerInfo();
145};
146
151class epicsShareClass AuthenticationSession
152{
153public:
154 POINTER_DEFINITIONS(AuthenticationSession);
155
156 virtual ~AuthenticationSession();
157
160 virtual epics::pvData::PVStructure::const_shared_pointer initializationData()
161 { return epics::pvData::PVStructure::const_shared_pointer(); }
162
166 virtual void messageReceived(epics::pvData::PVStructure::const_shared_pointer const & data) {}
167
172 virtual void authenticationComplete(const epics::pvData::Status& status) {}
173};
174
176class epicsShareClass AuthenticationPluginControl
177{
178public:
179 POINTER_DEFINITIONS(AuthenticationPluginControl);
181
184 virtual void sendSecurityPluginMessage(epics::pvData::PVStructure::const_shared_pointer const & data) = 0;
185
194 const std::tr1::shared_ptr<PeerInfo>& peer) = 0;
195};
196
198class epicsShareClass AuthenticationPlugin
199{
200public:
201 POINTER_DEFINITIONS(AuthenticationPlugin);
202 virtual ~AuthenticationPlugin();
203
209 virtual bool isValidFor(const PeerInfo& peer) const { return true; }
210
220 virtual std::tr1::shared_ptr<AuthenticationSession> createSession(
221 const std::tr1::shared_ptr<PeerInfo>& peer,
222 std::tr1::shared_ptr<AuthenticationPluginControl> const & control,
223 epics::pvData::PVStructure::shared_pointer const & data) = 0;
224};
225
228class epicsShareClass AuthenticationRegistry
229{
230 EPICS_NOT_COPYABLE(AuthenticationRegistry) // would need locking
231public:
232 POINTER_DEFINITIONS(AuthenticationRegistry);
233
234private:
236 map_t map;
237 mutable epicsMutex mutex;
238public:
240
245
248
250 void snapshot(list_t& plugmap) const;
251
258 void add(int prio, const std::string& name, const AuthenticationPlugin::shared_pointer& plugin);
260 bool remove(const AuthenticationPlugin::shared_pointer& plugin);
263 AuthenticationPlugin::shared_pointer lookup(const std::string& name) const;
264};
265
268class epicsShareClass AuthorizationPlugin
269{
270public:
271 POINTER_DEFINITIONS(AuthorizationPlugin);
272
273 virtual ~AuthorizationPlugin();
274
276 virtual void authorize(const std::tr1::shared_ptr<PeerInfo>& peer) =0;
277};
278
279class epicsShareClass AuthorizationRegistry
280{
281 EPICS_NOT_COPYABLE(AuthorizationRegistry)
282public:
283 POINTER_DEFINITIONS(AuthenticationRegistry);
284
285 static AuthorizationRegistry &plugins();
286
287 AuthorizationRegistry();
288 ~AuthorizationRegistry();
289
290private:
292 map_t map;
293 size_t busy;
294 mutable epicsMutex mutex;
295public:
296
297 void add(int prio, const AuthorizationPlugin::shared_pointer& plugin);
298 bool remove(const AuthorizationPlugin::shared_pointer& plugin);
299 void run(const std::tr1::shared_ptr<PeerInfo>& peer);
300};
301
306epicsShareFunc
307void osdGetRoles(const std::string &account, PeerInfo::roles_t& roles);
308
309}
310}
311
312#endif // SECURITY_H
constexpr _ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
Callbacks for use by AuthenticationSession.
Definition security.h:177
virtual void authenticationCompleted(const epics::pvData::Status &status, const std::tr1::shared_ptr< PeerInfo > &peer)=0
Called by server plugin to indicate the the exchange has completed.
virtual void sendSecurityPluginMessage(epics::pvData::PVStructure::const_shared_pointer const &data)=0
Send AUTHZ to peer with payload.
Actor through which authentication exchanges are initiated.
Definition security.h:199
virtual std::tr1::shared_ptr< AuthenticationSession > createSession(const std::tr1::shared_ptr< PeerInfo > &peer, std::tr1::shared_ptr< AuthenticationPluginControl > const &control, epics::pvData::PVStructure::shared_pointer const &data)=0
Begin a new session with a peer.
virtual bool isValidFor(const PeerInfo &peer) const
Allow this plugin to be advertised to a particular peer.
Definition security.h:209
bool remove(const AuthenticationPlugin::shared_pointer &plugin)
Remove an existing entry. Remove true if the entry was actually removed.
static AuthenticationRegistry & servers()
The server side of the conversation.
void add(int prio, const std::string &name, const AuthenticationPlugin::shared_pointer &plugin)
Add a new plugin to this registry.
void snapshot(list_t &plugmap) const
Save a copy of the current registry in order of increasing priority.
static AuthenticationRegistry & clients()
The client side of the conversation.
AuthenticationPlugin::shared_pointer lookup(const std::string &name) const
Fetch a single plugin explicitly by name.
A particular authentication exchange.
Definition security.h:152
virtual void authenticationComplete(const epics::pvData::Status &status)
For client plugins only.
Definition security.h:172
virtual epics::pvData::PVStructure::const_shared_pointer initializationData()
For client plugins only, call to find the payload returned with CONNECTION_VALIDATION.
Definition security.h:160
virtual void messageReceived(epics::pvData::PVStructure::const_shared_pointer const &data)
Called when an AUTHZ message is recieved from the peer.
Definition security.h:166
I modify PeerInfo after authentication is complete.
Definition security.h:269
virtual void authorize(const std::tr1::shared_ptr< PeerInfo > &peer)=0
Hook to modify PeerInfo.
void osdGetRoles(const std::string &account, PeerInfo::roles_t &roles)
Query OS specific DB for role/group names assocated with a user account.
Copyright - See the COPYRIGHT that is included with this distribution.
Information provded by a client to a server-type ChannelProvider.
Definition security.h:119
roles_t roles
Set of strings which may be used to modify access control decisions.
Definition security.h:135
pvData::PVStructure::const_shared_pointer aux
NULL or extra authority specific information.
Definition security.h:131
std::string peer
network address of remote peer. eg. "192.168.1.1:5075".
Definition security.h:124
std::string realm
scope of authority. eg. "mylab.gov"
Definition security.h:127
bool identified
Short-hand for authority!="anonymous".
Definition security.h:141
bool local
Short-hand for transport=="local".
Definition security.h:140
std::string authority
authentication mechanism used. eg. "anonymous" or "gssapi". Must not be empty.
Definition security.h:126
unsigned transportVersion
If applicable, the protocol minor version number.
Definition security.h:137
std::string account
aka. user name
Definition security.h:128
std::string transport
transport protocol used eg. "pva". Must not be empty.
Definition security.h:125