diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-18 22:45:06 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-18 22:45:06 +0100 |
| commit | 74f18c6264618187386a5dc8b1152faa8727bf53 (patch) | |
| tree | f3e233f6d79f6f0b8a9758aefb91ff3731793dee /src/server_register.c | |
| parent | 5f5e172cd2392952162398c85b07e6f6b7e69398 (diff) | |
| download | BobinkCOpcUa-74f18c6264618187386a5dc8b1152faa8727bf53.tar.gz BobinkCOpcUa-74f18c6264618187386a5dc8b1152faa8727bf53.zip | |
Extract configureAccessControl() into common
The access-control switch block was duplicated in server_lds.c and
server_register.c. Move it to a shared helper in common.c with a
Doxygen block that consolidates the rationale from both call sites.
Diffstat (limited to 'src/server_register.c')
| -rw-r--r-- | src/server_register.c | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/server_register.c b/src/server_register.c index 8a64d08..1514c92 100644 --- a/src/server_register.c +++ b/src/server_register.c @@ -13,7 +13,6 @@ #include <open62541/client.h> #include <open62541/client_config_default.h> -#include <open62541/plugin/accesscontrol_default.h> #include <open62541/plugin/log_stdout.h> #include <open62541/server.h> @@ -158,30 +157,7 @@ main (int argc, char **argv) UA_ServerConfig *serverConfig = UA_Server_getConfig (server); serverConfig->logging->context = (void *)(uintptr_t)logLevel; - /* Configure access control. UA_ServerConfig_setDefaultWithSecure- - SecurityPolicies sets certificate-only auth by default, so we must - always call UA_AccessControl_default to get the desired policy. */ - switch (serverAuth.mode) - { - case AUTH_ANONYMOUS: - retval = UA_AccessControl_default (serverConfig, true, NULL, 0, NULL); - break; - case AUTH_USER: - { - UA_UsernamePasswordLogin logins[1]; - logins[0].username = UA_STRING ((char *)serverAuth.user.username); - logins[0].password = UA_STRING ((char *)serverAuth.user.password); - retval - = UA_AccessControl_default (serverConfig, false, NULL, 1, logins); - break; - } - case AUTH_CERT: - /* cert auth — sessionPKI.verifyCertificate is set by createServer - via setDefaultWithSecureSecurityPolicies, so UA_AccessControl_default - will automatically advertise the X509 certificate token policy. */ - retval = UA_AccessControl_default (serverConfig, false, NULL, 0, NULL); - break; - } + retval = configureAccessControl (serverConfig, &serverAuth); if (retval != UA_STATUSCODE_GOOD) goto cleanup; |
