Cloudflare CDN Setup - Client Side

Overview

The purpose of the Cloudflare CDN Worker client side implementation is to inject the Arkose client side scripts into the HTML on a page such as Login or Registration. There are 2 versions available on the Github page, one for a Button trigger and the other for a Form Submission trigger. Both versions will store a Cookie containing the Arkose Token which can then be verified using a second worker.

Cloudflare Setup

Step 1. Creating a Worker

  1. Log in to your Cloudflare account.

  2. Navigate to the Workers & Pages section in the side navigation panel and select Overview.

  1. After the page loads, click on the Create Application button.
  1. Select the Workers tab and click on Create Worker.
  1. Provide a name for the worker, then select Deploy.
  1. The Worker has been created, the next step is editing workers code.

Step 2. Edit Worker Code

  1. After deploying the Worker, click on Edit Code.
  1. Delete the sample code from the worker.js file.
  1. Open button-takeover or form-submit-takeover depending if using a Button trigger or a Form trigger. Copy and paste the code into the worker.js file.
  2. Click on Save and deploy

Step 3. Adding Variables to the Worker

  1. Navigate to the Workers summary and select the Settings tab.
  1. Select the Variables menu item from the side navigation panel.
  1. Add the following parameters as Worker Variables.

    VariableDescriptionSample
    publicKeyArkose labs private key obtained through https://portal.arkoselabs.com11111111-1111-1111-1111-111111111111
    arkoseMaxRetryCountThe number of retries to perform when there is an error2
    arkoseCookieNameThe name of the cookie that the Arkose token will be stored inarkose-Token
    arkoseErrorCookieNameThe name of the cookie that an Arkose error will be stored inarkoseError
    arkoseCookieLifeThe length of time the Arkose cookies should be active for (in milliseconds)300000 (5 minutes)
    buttonSelector (optional)The number of times to retry verification if there is an error# submitButton
    formSelector (optional)The querySelector string used for selecting the required form to protect# submitForm
  2. Click Save and deploy.


Step 4. Adding Triggers to the Worker

  1. Navigate to the Worker page and select the Triggers tab.
  1. Click on Add route.
  1. Enter the route name (no https is needed). This is the URL of the page containing the Login or Registration form.
  1. Select the domain Zone from the dropdown menu.
  1. Click on Add route.
  1. Once the route is added, the setup has been completed.