Skip to content

cURL Authentication with Escape

Description

The cURL authentication preset is designed for dynamic token generation and reuse:

  • cURL Command Parsing: Parses a cURL command and executes it in a secure sandboxed cURL simulator.
  • Dynamic Token Extraction: Extracts the authentication token from the cURL command's HTTP response.
  • Token Re-injection: Reinjects the extracted token into subsequent authenticated requests.

This preset is particularly useful for scenarios where authentication tokens are dynamically generated and need to be efficiently extracted and reused in ongoing requests.

The simulator supports a subset of arguments commonly used in cURL:

  • url: The URL for the HTTP request.
  • -X, --request: Specify a custom request method to use when communicating with the HTTP server.
  • -H, --header: Add a header to the request (can be used multiple times for multiple headers).
  • -b, --cookie: Add a cookie to the request (can be used multiple times for multiple cookies).
  • -d, --data, --data-ascii, --data-binary, --data-raw: Sends the specified data in a POST request.
  • -u, --user: Specify the user and password for server authentication.
  • -A, --user-agent: Sets the user agent string for the HTTP request.
  • -x, --proxy: Use the specified proxy.
  • -k, --insecure: Allow connections to SSL sites without certificates.
  • -L, --location: Follow redirects (the maximum number of redirects is defined by --max-redirs).
  • --max-redirs: Set the maximum number of redirections to follow for -L.

Note: The simulator does not support all cURL arguments. Adding unsupported arguments may result in an error.

Examples

presets:
-   type: curl
    injections:
    -   key: Authorization
        location: header
        prefix: Bearer
        variable: token
    extractions:
    -   name: token
        key: Authorization
        location: header
    users:
    -   username: user1
        curl: curl -X POST https://api.example.com/auth -d "username=user1&password=pass1"
presets:
-   type: curl
    injections:
    -   key: session_id
        location: cookie
        variable: sessionId
    extractions:
    -   name: sessionId
        key: Set-Cookie
        location: header
        regex: session_id=(\S+);
    users:
    -   username: user2
        curl: curl -X POST https://api.example.com/login -d "username=user2&password=pass2"

Extensive Configuration

Property Type Default Description
extractions * List[HTTPExtraction] The token extraction configuration used to extract the tokens from the HTTP response.
injections * List[HTTPInjection] The injection configuration used to inject the tokens into the HTTP requests.
type * Const[curl] curl
users * List[cURLUserPreset] The list of users to generate tokens for.

Objects

HTTPExtraction

Property Type Default Description
key * string The key to use for the extracted value, depending on the location
location * HTTPLocation The location of the HTTP request where the value should be extracted
name * string The name of the variable to store the extracted value into
regex string null The regex to use to extract the token from the key value. By default the entire value is taken.

HTTPInjection

Property Type Default Description
key * string The key to use for the injected token. Its usage depends on the location. For headers, cookies,and query parameters, this key describes the name of the header, cookie or query parameter. For a body location, the key is the field where the token should be injected within the request bodies
location * HTTPLocation The location of the HTTP request where the token should be injected
prefix string null A prefix to prepend to the token before it is injected
variable * string The name of a variable to retrieve to create the token's value. If not provided, the token will be infered as the first successful extraction of the procedure

cURLUserPreset

Property Type Default Description
cookies Dict[string, string] null Optional cookies injected during the authentication process and in authentified requests.
curl * string The curl command that is used to fetch the tokens for this user.
headers Dict[string, string] null Optional headers injected during the authentication process and in authentified requests.
username * string The arbitrary name that identifies the user.

Enums

HTTPLocation

Value
header
cookie
body
query