Open Automation Software
Moving Data From Anywhere to Anywhere
1-303-679-0898

Authentication

To ensure that all requests for server data be performed by an authorized user, the OAS Web HMI Script Library attaches an authentication token to each request. This token is generated by the Open Automation Software Server when provided a valid credential.

The token will expire after a period of disuse, or when the Open Automation Software Server is restarted, so it should be generated dynamically when a page is initially accessed. Options for generating the token are:

  • ASP.NET
  • Other Web Technologies
  • Client-Side Authentication
  • Java Script Authentication

ASP.NET

When a page is initially rendered, a call can be made to the OPC Library to create the token, which can then be embedded in the page header.

VB.NET

C#

The credential used could be taken directly from the user’s login within your application, or it could be a standard credential established on the server for all users.

Other Web Technologies

Similar to ASP.NET, it is recommended that the authentication token be generated on the server so that credentials are not passed from client to server, and are only exchanged in server-to-server communication.

For non-.NET technologies, you can use the REST API to make an authentication call to the Open Automation Software Server.

Client-Side Authentication

If you are operating within a secure network, and are not concerned about passing credentials between clients and the Open Automation Software Server, you can perform the authentication from within client script.

The following Javascript code will perform the server authentication and then begin refreshing the page with server data:

Java Script Authentication

In javascript, code can kick off an authentication by just calling the following:

OPC.authenticate(username,password);

What happens

In context, the steps would be as follows:

  1. Collect some credentials on the client, this can be from a form, or from any other client script
  2. Call OPC.authenticate() using those credentials
  3. The OAS Service will validate the credential and return a token, which will then be applied and used for all subsequent callbacks from the client library.
  4. If you wish to cache this token on the client, you can get it from the OPC.token property, and then use it on other screens in the OPC_config settings so there’s no need to call OPC.authenticate again when switching pages or screens.

Example

Here’s an example in javascript which does all of this. The do_authentication function would be called on a login form that contains username and password fields.