Install the Leakstream integration
Install Axur Leakstream from Azion Marketplace and run it on a firewall to flag login requests that use leaked credentials.
You install the Axur Leakstream integration from Azion Marketplace and run it on a Firewall, from Azion Console. Leakstream monitors the internet for leaked credentials, and checks whether a username and password combination was exposed in a known data breach. Use it to protect your e-commerce from checker attacks and your users’ credentials. The function extracts the username and password from the body of a login request, queries the Axur Leakstream API, and adds custom headers to the request. A second function reads those headers and blocks the request, redirects the user, or starts a secondary verification flow.
Six objects have to exist before a request is checked: the installed function, a firewall carrying the Functions module, a Leakstream function instance, a response function instance, two Rules Engine rules with the Run Function behavior, and a workload deployment bound to the firewall. Each section below creates them.
Prerequisites
- An Azion account. To sign in, refer to How to access Azion Console.
- An application served by a workload, whose deployment you bind to the firewall in the last section.
- An Axur account with a Leakstream plan that matches the size of your customer base.
- An Axur API Token, which you get after Axur enables your account.
- The Azion CLI installed and authorized, for the last section.
- Turning on a product or a module can generate usage costs. For more information, refer to Pricing.
Install the integration
The function is installed once per account. To install it:
Access Azion Console > Marketplace.
Enter Leakstream in the Search on Marketplace field, then select the integration’s card. Browsing the cards and the categories reaches the same page.
The card shows Successfully installed! and Latest version installed!, and the function appears in the Function list of the Create Instance drawer.
Create the firewall
The firewall is where the functions are instanced and where the rules that run them live. To create one:
Access Azion Console > Firewalls, then create a firewall.
In the General section, enter a Name. For example: leakstream-firewall.
In the Modules section, turn on the Functions switch.
The firewall shows a Functions Instances tab while the Functions module stays on. To use an existing firewall instead, turn on its Functions module and save it. For every setting on this form, refer to Set a firewall’s main settings.
Create the function instance
The instance holds your Axur API Token and the names of the login fields. To create it:
In Firewalls, select your firewall, then select the Functions Instances tab.
A firewall that has no instance shows the same action as Function Instance. The Create Instance drawer opens.
In Name, enter a name. For example: leakstream.
In Function, select the Axur Leakstream function. The list holds only the functions that run on a firewall.
In Arguments, the editor is prefilled with the integration’s default arguments in JSON. Enter your values, as the next section describes.
The instance is listed in the Functions Instances tab.
Arguments
The instance takes your API Token and the fields to read:
| Variable | Required | Description |
|---|---|---|
api_key | Yes | The API Token from your Axur account. Required unless the AXUR_API_V1_LEAKSTREAM_API_KEY environment variable is set |
username_field | Yes | The name of the request body field that holds the username. Required unless the AXUR_API_V1_LEAKSTREAM_USERNAME_FIELD environment variable is set |
password_field | No | The name of the request body field that holds the password |
password_hash_type | No | The hashing algorithm of the password. Accepted values: md5, sha1, sha224, sha256, sha384, sha512 |
execute_hashing | No | When true, the function hashes the password with SHA-256 before it sends the password to the Axur API. Use it when the frontend does not hash the password |
leakstream_timeout | No | The connection timeout, in milliseconds, for requests to the Axur API. The default is 60000 (60 seconds) |
Headers the function adds
The Leakstream function adds these headers to the request object:
| Header | Value | Description |
|---|---|---|
axur-leakstream-leaked | true | The username and password combination was found in a data breach |
axur-leakstream-username-leaked | true | The username alone was found in a data breach |
axur-leakstream-missing-username | true | The username field was not found in the request body |
axur-leakstream-error | timeout, invalid-content-type, or an HTTP status code | An error occurred during the call to the Axur API |
Create the response function instance
The Firewall Rules Engine criteria cannot match custom request headers. For this reason, the blocking logic lives in a second function, which reads the axur-leakstream-leaked header from the request object and returns a response.
The function below returns an HTML warning page when the header is true:
Create a firewall function with this code, then instance it on the same firewall, with the steps of the previous section. For how to create a function that runs on a firewall, refer to Run a function on a firewall.
Create the rules
The integration uses two rules on the same endpoint. The first rule runs the Leakstream function, and the second rule runs the response function that acts on the headers. A Rules Engine for Firewall rule selects the requests that reach an instance, through a Run Function behavior.
To create the rule that runs the Leakstream function:
In Firewalls, select your firewall, then select the Rules Engine tab.
In Name, enter a name. For example: Run Leakstream.
In the Criteria section, limit the check to your login or account-creation endpoint, not every request. For example: if Request Method is equal to POST and Request URI matches /login.
In the Behaviors section, select Run Function, then select the Leakstream instance.
To create the rule that acts on the result:
In Name, enter a name. For example: Block leaked credentials.
In the Criteria section, match the same endpoint as the first rule. For example: if Request Method is equal to POST and Request URI matches /login.
In the Behaviors section, select Run Function, then select the response function instance.
Bind the firewall to the workload
The binding is on the workload’s deployment, so create a deployment that names both the application and the firewall:
The command prints the id of the new deployment:
Requests to the workload’s domain reach the firewall, and the rules run the Leakstream instance and the response function instance on the login endpoint.