问题
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