Custom device posture integration
Cloudflare Zero Trust allows you to enforce custom device posture checks on your applications. This involves configuring a WARP service-to-service integration that periodially calls the external API of your choice, whether it is a third-party endpoint provider or a home built solution. When called, the API will receive device identifying information from Cloudflare and be expected to return a value between 0
to 100
. You can then set up a device posture check that determines if the returned value counts as a pass or fail; for example, you could allow access to a user only if their device has a posture value greater than 60
.
sequenceDiagram participant WARP participant Cloudflare Access participant External API WARP->>Cloudflare Access: Client ID and Secret Cloudflare Access->>External API: Application token WARP->>External API: JSON with user and device identity External API-->>WARP: JSON with 0-100 result
The custom service provider integration works with any API service that meets the following specifications. For an example of a custom device posture integration API, refer to our Cloudflare Workers sample code ↗.
The WARP client authenticates to the external API through Cloudflare Access. The external API should validate the application token issued by Cloudflare Access to ensure that any requests which bypass Access (for example, due to a network misconfiguration) are rejected.
Cloudflare will pass the following parameters to the configured API endpoint. You can use this data to identify the device and assign a posture score. For some devices, not all identifying information will apply, in which case the field will be blank. A maximum of 1,000 devices will be sent per a request.
Field | Description |
---|---|
device_id | Device UUID assigned by the WARP client |
email | Email address used to authenticate the WARP client |
serial_number | Device serial number |
mac_address | Device MAC address |
virtual_ipv4 | Device virtual IPv4 address |
hostname | Device name |
Example request body:
For each Cloudflare device_id
, the API service is expected to return a posture score and optionally a third-party device ID.
Field | Description |
---|---|
s2s_id | Third party device ID (empty string if unavailable) |
score | Integer value between 0 - 100 |
Example response body:
WARP uses an Access Client ID and Access Client Secret to securely authenticate to the external API. If you do not already have an Access Client ID and Access Client Secret, create a new service token.
Next, secure the external API behind Cloudflare Access so that WARP can authenticate with the service token. To add the API endpoint to Access:
-
Create a self-hosted application for your API endpoint.
-
Add the following Access policy to the application. Make sure that Action is set to Service Auth (not Allow).
Action Rule type Selector Value Service Auth Include Service Token <TOKEN-NAME>
To create a custom service-to-service integration:
- In Zero Trust ↗, go to Settings > WARP Client.
- Scroll down to Third-party service provider integrations and select Add new.
- Select Custom service provider.
- Enter any name for the provider. This name will be used throughout the dashboard to reference this connection.
- In Access client ID and Access client secret, enter the Access service token used to authenticate to your external API.
- In Rest API URL, enter the external API endpoint that Cloudflare will query for posture information (for example,
https://api.example.com
). For more information, refer to External API requirements. - In Polling frequency, choose how often Cloudflare Zero Trust should query the external API for information.
- Select Test and save. The test checks if Cloudflare can authenticate to the API URL using the provided Access credentials.
Next, configure a device posture check to determine if a given posture score constitutes a pass or fail.
- In Zero Trust ↗, go to Settings > WARP Client > Service provider checks.
- Select Add new.
- Select the Custom service provider provider.
- Enter any name for the posture check.
- Configure the attributes required for the device to pass the posture check.
- Select Save.
- To test, go to Logs > Posture and verify that the service provider posture check is returning the expected results.
You can now use this posture check in a device posture policy.
Selector | Description | Value |
---|---|---|
Score | Posture score returned by external API | 0 to 100 |