Skip to main content

User authentication

Goal

Enable username/password access to your scripted OPC UA server.

Add a simple user manager

Add the following userManager block to your server options when you create the OPCUAServer instance:

const server = new opcua.OPCUAServer({
port: msg.port || 4840,
nodeset_filename: [opcua.nodesets.standard],
serverInfo: {
applicationUri: `urn:${msg.endpoint}`,
productUri: "MyOPCUAServer",
applicationName: { text: "MyOPCUAServer", locale: "en-US" },
isOnline: true
},
userManager: {
isValidUser: (username, password) => {
return username === "admin" && password === "secret";
}
}
});

Notes

  • You can validate users against a list, a database, or a file.
  • For more advanced authentication (certificates, tokens), see the security page.

Next step

Continue with security policies and certificates.

Further reading

For more tips and examples, see the Sterfive book node-opcua by example.