LESSON

Securing Event Handlers

Description

Learn how to set up security in an event script using the system.security.getRoles function. This function can be used in any script in Ignition that runs in a Client.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] Security can be added to any of the event handlers in Ignition. To demonstrate that, we're going to drag a button onto my window from the component palette. Right-clicking on the button, and selecting "scripting," will bring up the button's scripting editor window. On the left here, we see a list of all the event handlers associated with this button. We go over these event handlers in more detail in the scripting section of Inductive University. But for this lesson, we will use the action perform event handler. I will configure a navigation script. I'm going to tell the button to open and center my window named, "Pop-up." On the bottom here, we will see a section for action qualifiers. Clicking on the security button brings up a menu that allows you to select the set of rules to be required for this navigation action to work. I will configure this to require an administrator role for my navigation action to work. Heading over to the script editor tab, we see that Ignition has generated our navigation script for us. Diving into the code, you'll see that line six uses the, "getRoles," system security function. This function will return the roles of the currently logged-in user. All line six is doing is checking if administrator role is part of the list of roles the currently logged-in user belongs to. If the logged-in user does, in fact, have the administrator role, then the open window function and the center window function will be executed. If they user does not have the administrator as its role, an error box will appear notifying the user they have insufficient privileges. Any of your scripts can use this exact same system. If my security condition is met, then go ahead and execute the script.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.