Information This guide explains how to configure the security settings for the Checkbox API ,including CORS, HTTP headers, HSTS, and path filtering. This feature is supported from version 8.20.0 of the Checkbox.
Configuration The API security settings are configured in the appsettings.json file located in your API deployment directory (by default, it is checkbox/api-core).
CORS "apiCors": {
"origins": [
"https://app.example1.com",
"https://app.example2.com",
"https://app.example3.com"
],
"preflightMaxAge": 86400,
"disabled": false,
"allowedMethods": ["GET", "POST", "PUT"],
"allowedHeaders": ["Content-Type", "Authorization", "X-Requested-With"],
"allowCredentials": true
},
Property Type Default Description originsstring[] []List of allowed origins. Empty array allows all origins (not recommended for production) preflightMaxAgeint 86400How long browsers can cache CORS preflight responses (in seconds) disabledbool falseDisable CORS entirely allowedMethodsstring[] []Specific HTTP methods to allow. Empty allows all methods allowedHeadersstring[] []Specific headers to allow. Empty allows all headers allowCredentialsbool falseAllow credentials (cookies, authorization headers) in CORS requests
HTTP Strict Transport Security forces HTTPS connections "apiHsts": {
"disabled": false,
"preload": false,
"includeSubDomains": true,
"maxAgeDays": 365
}
Property Type Default Description disabledbool falseDisable HSTS preloadbool falseInclude in browser preload lists includeSubDomainsbool trueApply to all subdomains maxAgeDaysint 30How long browsers should remember HTTPS requirement
Add custom or remove HTTP headers. "apiHeaders": {
"addCustom": {
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "strict-origin-when-cross-origin"
},
"remove": ["X-Powered-By", "X-AspNet-Version"]
}
Property Type Default Description addCustomDictionary<string, string> {}Headers to add to responses removestring[] []Headers to remove from responses
Path Filtering Configuration "apiPathFiltering": {
"invalidCharacters": ["%", "..", ";"]
} Property Type Default Description invalidCharactersstring[] []Characters/strings to block in URL paths
Considerations Blocking is case-insensitive May block legitimate requests (e.g., emails in URLs if blocking @) Test thoroughly with your application's URL patterns Applying Configuration Changes Edit appsettings.json in your API deployment directory Save the file Restart the API website in IIS
0 Comments