Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Use SIL to the maximum Part 5

Part 4

Remote Systems

The Remote Systems menu option lets you

  • Add connections to remote systems and call sil scripts from these remote systems.
  • Set permissions to call SIL scripts by SIL REST API.

You can find Vendor's information here.

Screenshot 2020-05-25 at 11.13.02.png

Let's first create a connection to a remote system and call a sil script from this remote system.

I have two Jira instances running on localhost:2990/jira and localhost:8080.

I have this SIL script on localhost:8080 called test.sil:

logPrint("ERROR", "I am called from " + argv[0]);

This scripts accepts a parameter and logs an error message into the atlassian-jira.log file with a message which includes this parameter.

Now on localhost:2990/jira I go to cog item -> Manage Apps -> Remote Systems, push the Add Remote button and provide data for my localhost:8080 Jira instance:

Screenshot 2020-05-25 at 11.36.53.png

Now push the Save button and create a script on localhost:2990/jira which will call the test.sil from localhost:8080:

call("my_ext_jira", "test.sil", "localhost:2990/jira")

The first parameter is the name of our connection (my_ext_jira).

The second parameter is the name of the script which will be executed on the remote system.

The third parameter is the additional parameter which will be passed to our test.sil and we will take the value of this parameter as argv[0].

Now let's run the script and have a look in the logs on localhost:8080. We will see the following line:

2020-05-25 08:30:57,944+0000 pool-38-thread-2 ERROR admin 510x101x1 3sauem 172.26.0.1 /rest/keplerrominfo/refapp/latest/async-script/runScript [c.k.s.lang.routines.LogPrintRoutine] I am called from localhost:2990/jira

It means that we successfully called a SIL script on localhost:8080 from localhost:2990/jira.

Next let's have a look at the Security section of the Remote Systems menu option.

Suppose we have two scripts on our localhost:2990/jira.

test.sil

call("my_ext_jira", "test.sil", "localhost:2990/jira")

test1.sil

runerLog("Hello World");

And also I have a user called user1 who does not have the Jira Administrator permission and I want this user to be able to execute inline scripts and sil scripts on the file system by SIL REST API.

Let's go to Remote Systems:

Screenshot 2020-05-25 at 11.46.18.png

We will be working with the Grant execute inline, Grand read and Grant execute buttons from the Security section.

First let's try to execute an inline script by user1.

http://localhost:2990/jira/rest/keplerrominfo/refapp/1.0/async-script/runScript

With this JSON:

{
   "source" : {
    "type": "INLINE",
    "code": "return 1;"
    }
}

And we have the 403 Forbidden error.

Now let's push the Grant execute inline button and add this grant to user1:

Screenshot 2020-05-25 at 12.08.11.png

And now we got the 200 response which means that the script was executed successfully.

Now let's try to execute the test1.sil file under user1. This time the JSON will look like this:

{
   "source": {
        "type": "FILE",
        "code": "test1.sil"
    }
}

And we get the 403 Forbidden error. Now let's permit user1 to execute the test1.sil file, push the Grant execute button:

Screenshot 2020-05-25 at 12.12.36.png

Let's execute the script and this time the response code is 200.

LDAP Configuration

You can provide a connection to your LDAP. You can find Vendor's information here.

Screenshot 2020-05-25 at 12.26.05.png

I run a docker with a ldap server from here.

docker run -p 389:389 -p 636:636 --name my-openldap-container --env LDAP_ADMIN_PASSWORD="adminadmin" --detach osixia/openldap:1.3.0

Let's push the Add LDAP button and configure our connection:

Screenshot 2020-05-25 at 12.28.58.png

The only available option for the Directory field is Active Directory. But it does not mean that you can make a connection only to Microsoft Active Directory. You can use any LDAP server. In my case I used open ldap.

Now we can select data from this ldap.

Let's try to select data with the ldapUserList routine:

runnerLog(ldapUserList({"cn", "uid"}, "objectClass=*", "myldap"));

And I successfully chose the admin user from my ldap.

Screenshot 2020-05-25 at 12.34.56.png

Part 6

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events