Creating Static Integrations with Authentication
The more advanced type of static integrations that can be built are the ones that employ authentication. In this step-by-step guide, you will learn how to create an SSH block with all mandatory authentication details. Commands will be executed only when the authentication check has passed.
Setting up this static integration type involves the following steps:
Create a Folder Structure – Define and create a folder structure for the integration. It should have the following structure:
auth schemas- – references the integration name
icons – they are optional
Create a manifest.json file – You need to create the manifest.json file in the main directory of the integration. In it, you can add all dependencies that are used in the package.json file.
The following parameters can be defined here:
manifest_version – the version of the manifest file. You can update the versioning when updating the file to bring awareness of changes.
name – The name of the integration package.
version – The version of the integration package.
changelog – Allows you to set changelog entries referencing notes for each integration package
description – A description of the integration package.
author – you can define the author here. Sub-parameters are the “name” and “email” of the associated author.
dependencies – you can define any dependent package.
Putting an image inside the icons folder (optional)
The file should be small-sized and with a transparent background in a SVG format.
The associated icon should be named after the integration name.
Create a JSON file inside the authschemas/integrationName directory – Create this file to match the integration name. Inside the Schema/properties enter all fields that are required for the successful authentication. In our example, the host, port, username, and password fields are of plaintext type. If necessary, you can add a boolean or string type field with enum arrays.
In our example, the host, port, and username are mandatory fields.
authenticate.js example code block
With the second file called request.js you can make calls to the integration and also hold inside the logic for the authentication data preparation.
request.js example code block
Create the workflow schema block – Create the containing the JSON guidance code that controls how the block will be shown and how it will handle input and output data. There are no strict requirements for the filename. In comparison with the previous code sample, there are some differences to note. There are no entryNode and exitNode. Instead, the first element is called start. In this code, there are variables called authKey that contain the meta.authType property, which must be set as the same name as serviceName in the authschemas/integrationName/integrationName.json file.
Example flow code block
The function parameter of the nodes in this example includes the following elements:
start as the first element of process.nodes. It calls authenticate.js and passes on the authentication key.
start example code block
process_parameters, a one-liner that prepares objects into block fields.
An example code block utilizing username, password, and command properties as input fields.
An example request code block
Here finish sets the output field with the result of the request
Package the contents in a ZIP file – Once all relevant files are ready, they can be packaged. Create a ZIP package with all files and name them using an appropriate name following this template: integrationName_version.zip.
Import the package into a service instance – Follow the steps outlined in the Integrations page to import your custom package.
Create a workflow with the new package – You can create a new authentication configuration for the new integration package. Use the Authentications section in the Workflow Editor.
Enter the mandatory fields in the shown screen.
Once this is complete, your custom integration package will show up in the Workflow Editor.
For a sample solution drag a SSH block onto the Workflow Editor.
Choose the new authKey and the Command fields. You set the credentials access using the username and password fields.
You can now start your workflow!