captcha_csrf
The `captcha_csrf` directive defines the name of the CSRF variable used in conjunction with CAPTCHA validation.
Description
The captcha_csrf directive is part of the NGINX Captcha Module and is utilized to specify the name of the Cross-Site Request Forgery (CSRF) variable associated with the CAPTCHA functionality. This directive is essential for maintaining security by ensuring that the CAPTCHA being validated corresponds with the expected CSRF token. By default, this variable is set to 'csrf', but it can be customized to meet the needs of a specific application or implementation.
By utilizing the captcha_csrf directive, an administrator can define the CSRF variable name that is used during the CAPTCHA validation phase. When a user submits a form that includes a CAPTCHA, the system validates both the CAPTCHA response and the CSRF token to ensure that the request is legitimate, thus protecting against CSRF attacks. The configuration of this directive typically takes place within the context of either http, server, or location, allowing flexibility in setting it based on the needs of different areas of the application.
This directive is particularly useful in configuration scenarios where there may be multiple forms or endpoints that require differing CSRF variable names. By specifying captcha_csrf, you can ensure that the correct variable is checked during the CAPTCHA validation process, thereby enhancing the overall security of the application workflow.
Config Example
location =/login {
captcha_csrf my_csrf_var;
...
}Ensure the CSRF variable specified is consistent across the application forms and validation logic.
If the CSRF variable is not properly set, it may lead to CAPTCHA verification failures, causing legitimate requests to be denied.