Configuration Options
Configuring the rust module in Fastly is done via the Compute@Edge Dictionary.
Required Configurations
Optional Configurations
Auto deploying the configurations
We have created the pxconfig.sh script to be used to populate the configurations in the Dictionary automatically. Following is an example to populate the required configurations only:
Enforcer Configuration
To manually add or update the configurations, you can use Config Stores in the Fastly Web UI. The configurations should be added to the Config Store named PXConfig as key-value pairs.
Configuration types:
- String: A sequence of characters, without quotes. Example:
my_string - Boolean: A true or false value. Example:
trueorfalse - Number: A numeric value. Example:
100 - List: A comma-separated list of values without quotes. Example:
value1, value2 - Regex List: A comma-separated list of regular expressions without quotes. Example:
^/graphql$, ^/api/graphql$
GraphQL Configurations
px_graphql_enabled
Whether the enforcer should attempt to parse and report information about GraphQL operations on incoming requests.
Default: false
px_graphql_routes
A comma-separated list of regex routes that will be checked for sensitive GraphQL operations. If a request’s route matches any of the regexes in this list, it will be checked for sensitive GraphQL operations as configured in px_sensitive_graphql_operation_types and px_sensitive_graphql_operation_names. If the request contains a sensitive operation, it will trigger a server call to HUMAN servers every time that operation is performed, regardless of cookie state.
Default: ^/graphql$
px_sensitive_graphql_operation_types
A comma-separated list of operation types (query, mutation, or subscription) that should be considered sensitive. If one or more GraphQL operations on an HTTP request is found to have a type matching the list configured here, it will trigger a Risk API call even if the request contains a valid, unexpired cookie.
Default: ""
px_sensitive_graphql_operation_names
A comma-separated list of operation names that should be considered sensitive. If one or more GraphQL operations on an HTTP request is found to have a name matching the list configured here, it will trigger a Risk API call even if the request contains a valid, unexpired cookie.
Default: ""
CORS support
px_cors_support_enabled
CORS (Cross-Origin Resource Sharing) is a mechanism that enables the server to indicate when a request contains cross-origin resources. It does so by adding special HTTP headers to the request, which permits the browser to load these resources. Without these headers, the browser may block requests to these resources for security reasons.
In most cases, CORS employs a two-stage procedure with a preliminary “preflight” request followed by the actual request. The preflight request checks if the actual request will be responded to. To learn more about different request types, see these examples.
In the Enforcer, CORS behavior must be configured to address both simple requests (without preflight) and more complex ones (with preflight). Enabling CORS support via this configuration will have the following effects:
- It will automatically add the following default CORS response headers to block responses resulting from CORS requests.
Default: false
Cors custom block response headers callback function
If the default CORS response headers are not sufficient, it is possible to completely customize the headers that should be added to all block responses resulting from CORS requests. If a callback function is defined, the default headers will not be added; only those headers specified in the returned vector will be added to the block response.
Functions definitions:
Default: None
px_cors_preflight_request_filter_enabled
This configuration disables enforcement for CORS preflight requests. When this configuration is set to true, CORS preflight requests will be filtered from the enforcer flow. That is, they will pass through the enforcer flow without triggering detection or block responses.
Default: false
Cors custom preflight handler
If a more customized approach is needed for handling CORS preflight requests, this custom function can be set to define the desired behavior. The custom function should receive the original HTTP request and return an object representing the HTTP response to be returned. If None is returned from the function, the Enforcer will continue processing the preflight request.
The px_cors_custom_preflight_handler will be invoked prior to determining whether or not to filter the request based on the px_cors_preflight_request_filter_enabled configuration. This allows for returning customized responses for preflight requests that meet certain conditions and filtering those that don’t meet these conditions.
Functions definitions:
Default: None