Use NI-Auth to restrict access to services hosted on Application Web Server

Updated Nov 30, 2023

Environment

Software

  • LabVIEW

When deploying a Web Service created in LabVIEW, you may want to restrict access rights to specific services. We will review how to use NI-Auth to restrict, change, and manage permissions to services accessible by username and password.

Login authentication by NI-Auth and authorization to HTTP requests are performed in the following three steps.
:

  1. Application Web Server settings
  2. Assigning Permissions in Web Services Created in LabVIEW
  3. Making HTTP Requests Using NI-Auth
  1. Application Web Server settings

    1. Logging in to Application Web Server and changing settings
      NI Web-based Configuration & Monitoring, which configures the Application Web Server, requires a Microsoft Edge browser in Internet Explorer compatibility mode to access http://localhost:3582/#Home. Detailed instructions can be found in this document. There is no method other than the above method for setting up Application Web Server.

      User names and passwords managed by NI-Auth can be created and set on the following screen. In addition, you can manage the Web Service that can be accessed according to the authority granted to each user here. Here, the password for the admin account is set as welcome, and the authority auth1 created by the method described later is granted.

      Change admin password.png
    2. Creating Permissions and Assigning to Users Assigning which Web Services can be accessed is done by creating and using permissions. Here, for example, create an authority called auth1. Assign this auth1 permission only to admin. Now make sure that nobody is assigned auth1. Since the functions that can be used by the authority assigned to everyone are not managed by NI-Auth, they can be used without the need for user name and password authentication.

      Create authority.png
  1. Assigning Permissions in Web Services Created in LabVIEW

    1. Permission Mapping in Web Service To grant permission as a usage condition for a specific HTTP request, you need to select the application web server from the web service properties and add the permission as shown below. You can check how to create the following Web Service in this document.
      Permission assignment.png
  1. ​Making HTTP Requests with NI-Auth

    1. NI-Auth authentication with OpenHandle.vi
      LabVIEW's OpenHandle.vi is required for user name and password authentication by NI-Auth. By using the user name and password of this function, the authority mapped to each HTTP request and the authority possessed by each user are compared, and it is possible to implement the behavior that the HTTP quest is executed only at login as shown below.

      NIAuthTest.png 

Next Steps

  • Languages such as Python and C# cannot use NI-Auth.