ua_plugin_access_control.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  7. */
  8. #ifndef UA_PLUGIN_ACCESS_CONTROL_H_
  9. #define UA_PLUGIN_ACCESS_CONTROL_H_
  10. #include "ua_types.h"
  11. _UA_BEGIN_DECLS
  12. struct UA_AccessControl;
  13. typedef struct UA_AccessControl UA_AccessControl;
  14. /**
  15. * .. _access-control:
  16. *
  17. * Access Control Plugin API
  18. * =========================
  19. * The access control callback is used to authenticate sessions and grant access
  20. * rights accordingly. */
  21. struct UA_AccessControl {
  22. void *context;
  23. void (*deleteMembers)(UA_AccessControl *ac);
  24. /* Supported login mechanisms. The server endpoints are created from here. */
  25. size_t userTokenPoliciesSize;
  26. UA_UserTokenPolicy *userTokenPolicies;
  27. /* Authenticate a session. The session context is attached to the session
  28. * and later passed into the node-based access control callbacks. The new
  29. * session is rejected if a StatusCode other than UA_STATUSCODE_GOOD is
  30. * returned. */
  31. UA_StatusCode (*activateSession)(UA_Server *server, UA_AccessControl *ac,
  32. const UA_EndpointDescription *endpointDescription,
  33. const UA_ByteString *secureChannelRemoteCertificate,
  34. const UA_NodeId *sessionId,
  35. const UA_ExtensionObject *userIdentityToken,
  36. void **sessionContext);
  37. /* Deauthenticate a session and cleanup */
  38. void (*closeSession)(UA_Server *server, UA_AccessControl *ac,
  39. const UA_NodeId *sessionId, void *sessionContext);
  40. /* Access control for all nodes*/
  41. UA_UInt32 (*getUserRightsMask)(UA_Server *server, UA_AccessControl *ac,
  42. const UA_NodeId *sessionId, void *sessionContext,
  43. const UA_NodeId *nodeId, void *nodeContext);
  44. /* Additional access control for variable nodes */
  45. UA_Byte (*getUserAccessLevel)(UA_Server *server, UA_AccessControl *ac,
  46. const UA_NodeId *sessionId, void *sessionContext,
  47. const UA_NodeId *nodeId, void *nodeContext);
  48. /* Additional access control for method nodes */
  49. UA_Boolean (*getUserExecutable)(UA_Server *server, UA_AccessControl *ac,
  50. const UA_NodeId *sessionId, void *sessionContext,
  51. const UA_NodeId *methodId, void *methodContext);
  52. /* Additional access control for calling a method node in the context of a
  53. * specific object */
  54. UA_Boolean (*getUserExecutableOnObject)(UA_Server *server, UA_AccessControl *ac,
  55. const UA_NodeId *sessionId, void *sessionContext,
  56. const UA_NodeId *methodId, void *methodContext,
  57. const UA_NodeId *objectId, void *objectContext);
  58. /* Allow adding a node */
  59. UA_Boolean (*allowAddNode)(UA_Server *server, UA_AccessControl *ac,
  60. const UA_NodeId *sessionId, void *sessionContext,
  61. const UA_AddNodesItem *item);
  62. /* Allow adding a reference */
  63. UA_Boolean (*allowAddReference)(UA_Server *server, UA_AccessControl *ac,
  64. const UA_NodeId *sessionId, void *sessionContext,
  65. const UA_AddReferencesItem *item);
  66. /* Allow deleting a node */
  67. UA_Boolean (*allowDeleteNode)(UA_Server *server, UA_AccessControl *ac,
  68. const UA_NodeId *sessionId, void *sessionContext,
  69. const UA_DeleteNodesItem *item);
  70. /* Allow deleting a reference */
  71. UA_Boolean (*allowDeleteReference)(UA_Server *server, UA_AccessControl *ac,
  72. const UA_NodeId *sessionId, void *sessionContext,
  73. const UA_DeleteReferencesItem *item);
  74. };
  75. _UA_END_DECLS
  76. #endif /* UA_PLUGIN_ACCESS_CONTROL_H_ */