This tutorial guides you through the process of building a sample application using the REST API. The goals for the tutorial are to gain competence and familiarity with the process of developing a DualShield application.
This tutorial uses Python as the programming language. It assumes:
- You have installed DualShield platform.
- You can write, test, and troubleshoot a Python application.
Building a DualShield application is actually quite simple. There are only 3 basic steps:
- Register an API Agent
- Download the Agent Certificate
- Write your codes
Register an API Agent
To DualShield, your application is an API agent. Therefore, the very first step is to register your application as an API Agent in the DualShield authentication server.
To register an agent, you must first create the following objects in DualShield:
- A domain
- A realm
- A logon procedure
- An application
The type of the logon procedure should be set as "Web SSO"
And the logon procedure does not have to contain any logon steps.
To register an API agent, select "Authenticaton | Agents" in the main menu, then click the "Register" button in the toolbar.
The type of the agent must be set to "API Agent".
Make sure that you select the application that you have created for the agent.
You can enable the "Check Agent IP" option for extra security. If this option is selected then you must provide the IP address of the machine where your application is running.
The communication protocol between the agent, i.e. your application and the DualShield is always HTTPS, therefore DualShield will create a SSL certificate for the agent.
The Agent Registration Data is not required.
Download the Agent Certificate
As mentioned, the communication protocol between your application and the DualShield is always HTTPS. Therefore you need to download the agent's certificate which will be required in your application codes.
You can use either PKCS12 or PEM certificate in your code.
To download a PEM format certificate, in the Agents list, click the context menu of your agent and select "Download | Agent SSL Certificate (PEM)". The certificate will be saved as "My Application.PEM". This PEM certificate contains both the certificate and the private key.
If you are using some programming language, like python, you might want to extract the private key separately. You can use the OpenSSL tool:
- Rename "My application.pem" to "apicert.pem"
- In the CMD console, execute:
openssl rsa -in apicert.pem -out apikey.pem
apikey.pem is the certificate's unencrypted private key.
To download a PKCS12 format certificate, select "Download | Agent SSL Certificate (PFX)".
Or if your application code is in JAVA, you can download a JKS store directly by selecting "Download | Agent SSL Certificate (JKS)"
Write a Test Application
Create a DualShield Class
class DualShield: |
Initialize DualShield Variables
host = 'dualshield.deepnetlabs.com' |
Replace the values of these variable with your own.
host: the host name (FQDN) of your DualShield server
port: the port number of the DualShield authentication server
keyFile: Your agent's private key file
certFile: Your agent's certificate file
domainname: The name of the domain that your agent is connected to
Create a Test Class
class TestDualShield(unittest.TestCase): |
Check the Connection
Call the"Hello" method in DualShieldto check the connection
def test_1_hello(self): | ]]></ac:plain-text-body></ac:structured-macro> |
Static Password Authentication
The authentication method for verifying Static Password is "SPASS"
def test_2_staticpass(self): | ]]></ac:plain-text-body></ac:structured-macro> |
One-Time Password Authentication
The authentication method for verifying Static Password is "OTP"
def test_3_verifySafeID(self): | ]]></ac:plain-text-body></ac:structured-macro> |
Deliver On-Demand Password
To deliver an on-demand password to a user via email message (SMTP)
def test_4_sendOTP(self): | ]]></ac:plain-text-body></ac:structured-macro> |
On-Demand Password Authentication
The authentication method for verifying On-Demand Password is "OTPoD"
def test_5_verifyODP(self): | ]]></ac:plain-text-body></ac:structured-macro> |
The complete Python application is in the file "TestAPI.py"