aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index cf364bb..9401392 100644
--- a/src/common.c
+++ b/src/common.c
@@ -6,6 +6,7 @@
#include "common.h"
#include <open62541/client_config_default.h>
+#include <open62541/plugin/accesscontrol_default.h>
#include <open62541/plugin/log_stdout.h>
#include <open62541/server_config_default.h>
@@ -305,6 +306,30 @@ resolveSecurityPolicyUri (const char *shortName)
}
/* ========================================================================
+ * Access Control
+ * ======================================================================== */
+
+UA_StatusCode
+configureAccessControl (UA_ServerConfig *config, const AuthConfig *auth)
+{
+ switch (auth->mode)
+ {
+ case AUTH_ANONYMOUS:
+ return UA_AccessControl_default (config, true, NULL, 0, NULL);
+ case AUTH_USER:
+ {
+ UA_UsernamePasswordLogin logins[1];
+ logins[0].username = UA_STRING ((char *)auth->user.username);
+ logins[0].password = UA_STRING ((char *)auth->user.password);
+ return UA_AccessControl_default (config, false, NULL, 1, logins);
+ }
+ case AUTH_CERT:
+ return UA_AccessControl_default (config, false, NULL, 0, NULL);
+ }
+ return UA_STATUSCODE_BADINTERNALERROR;
+}
+
+/* ========================================================================
* Output Formatting
* ======================================================================== */