userName/password Identity on OPC UA Server?

浪尽此生 提交于 2021-01-29 12:52:52

问题


In Client:

let  userIdentity = { userName: "user1", password: "user1" };
session = await client.createSession(userIdentity);

In Server

var userManager = {

isValidUser: function (userName, password) {

    if (userName === "user1" && password === "password1") {

        return true;
    }

    if (userName === "user2" && password === "password2") {
        return true;
    }

    return false;}};

When Clients create session with OPCUA Server, it will send userName/password Identity to activeSession on Server. How to I can know that userName when client connect to Server on my Server?


回答1:


You have to register the user manager on your server. See example

var server_options = {
...
userManager: userManager,

allowAnonymous: false,
};

var server = new OPCUAServer(server_options);

Then you your callback will be called



来源:https://stackoverflow.com/questions/61233566/username-password-identity-on-opc-ua-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!