ua_plugin_access_control.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #include "ua_types.h"
  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. typedef struct UA_AccessControl UA_AccessControl;
  23. struct UA_AccessControl {
  24. void *context;
  25. void (*deleteMembers)(UA_AccessControl *ac);
  26. /* Supported login mechanisms. The server endpoints are created from here. */
  27. size_t userTokenPoliciesSize;
  28. UA_UserTokenPolicy *userTokenPolicies;
  29. /* Authenticate a session. The session context is attached to the session
  30. * and later passed into the node-based access control callbacks. The new
  31. * session is rejected if a StatusCode other than UA_STATUSCODE_GOOD is
  32. * returned. */
  33. UA_StatusCode (*activateSession)(UA_Server *server, UA_AccessControl *ac,
  34. const UA_EndpointDescription *endpointDescription,
  35. const UA_ByteString *secureChannelRemoteCertificate,
  36. const UA_NodeId *sessionId,
  37. const UA_ExtensionObject *userIdentityToken,
  38. void **sessionContext);
  39. /* Deauthenticate a session and cleanup */
  40. void (*closeSession)(UA_Server *server, UA_AccessControl *ac,
  41. const UA_NodeId *sessionId, void *sessionContext);
  42. /* Access control for all nodes*/
  43. UA_UInt32 (*getUserRightsMask)(UA_Server *server, UA_AccessControl *ac,
  44. const UA_NodeId *sessionId, void *sessionContext,
  45. const UA_NodeId *nodeId, void *nodeContext);
  46. /* Additional access control for variable nodes */
  47. UA_Byte (*getUserAccessLevel)(UA_Server *server, UA_AccessControl *ac,
  48. const UA_NodeId *sessionId, void *sessionContext,
  49. const UA_NodeId *nodeId, void *nodeContext);
  50. /* Additional access control for method nodes */
  51. UA_Boolean (*getUserExecutable)(UA_Server *server, UA_AccessControl *ac,
  52. const UA_NodeId *sessionId, void *sessionContext,
  53. const UA_NodeId *methodId, void *methodContext);
  54. /* Additional access control for calling a method node in the context of a
  55. * specific object */
  56. UA_Boolean (*getUserExecutableOnObject)(UA_Server *server, UA_AccessControl *ac,
  57. const UA_NodeId *sessionId, void *sessionContext,
  58. const UA_NodeId *methodId, void *methodContext,
  59. const UA_NodeId *objectId, void *objectContext);
  60. /* Allow adding a node */
  61. UA_Boolean (*allowAddNode)(UA_Server *server, UA_AccessControl *ac,
  62. const UA_NodeId *sessionId, void *sessionContext,
  63. const UA_AddNodesItem *item);
  64. /* Allow adding a reference */
  65. UA_Boolean (*allowAddReference)(UA_Server *server, UA_AccessControl *ac,
  66. const UA_NodeId *sessionId, void *sessionContext,
  67. const UA_AddReferencesItem *item);
  68. /* Allow deleting a node */
  69. UA_Boolean (*allowDeleteNode)(UA_Server *server, UA_AccessControl *ac,
  70. const UA_NodeId *sessionId, void *sessionContext,
  71. const UA_DeleteNodesItem *item);
  72. /* Allow deleting a reference */
  73. UA_Boolean (*allowDeleteReference)(UA_Server *server, UA_AccessControl *ac,
  74. const UA_NodeId *sessionId, void *sessionContext,
  75. const UA_DeleteReferencesItem *item);
  76. };
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* UA_PLUGIN_ACCESS_CONTROL_H_ */