rest-assured/src/main/java/io/restassured/authentication/FormAuthConfig.java
public FormAuthConfig withCsrfFieldName(String fieldName) {
        notNull(fieldName, "CSRF field name");
        if (autoDetectCsrfFieldName) {
            throw new IllegalStateException("Cannot defined a CSRF field name since the CSRF field name has been marked as auto-detected.");
        }
        return new FormAuthConfig(formAction, userInputTagName, passwordInputTagName, logDetail, logConfig, fieldName, false, sendCsrfTokenAsFormParam, additionalInputFieldNames);
    }
public FormAuthConfig withCsrfFieldName(String fieldName) {
        notNull(fieldName, "CSRF field name");
        if (autoDetectCsrfFieldName) {
            throw new IllegalStateException("Cannot defined a CSRF field name since the CSRF field name has been marked as auto-detected.");
        }
        return new FormAuthConfig(formAction, userInputTagName, passwordInputTagName, logDetail, logConfig, fieldName, false, sendCsrfTokenAsFormParam, additionalInputFieldNames);
    }
public FormAuthConfig withCsrfFieldName ( String fieldName ) { notNull ( fieldName , "CSRF field name" ) ; if ( autoDetectCsrfFieldName ) { throw new IllegalStateException ( "Cannot defined a CSRF field name since the CSRF field name has been marked as auto-detected." ) ; } return new FormAuthConfig ( formAction , userInputTagName , passwordInputTagName , logDetail , logConfig , fieldName , false , sendCsrfTokenAsFormParam , additionalInputFieldNames ) ; }
Enable Cross-site request forgery (csrf) support when using form authentication by including the csrf value of the input field with the specified name.
For example if the login page looks like this:
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Login&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=&quot;j_spring_security_check_with_csrf&quot; method=&quot;POST&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;User:&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;j_username&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password:&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;password&quot; name=&quot;j_password&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot;&gt;&lt;input name=&quot;submit&quot; type=&quot;submit&quot;/&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input type=&quot;hidden&quot; name=&quot;_csrf&quot; value=&quot;8adf2ea1-b246-40aa-8e13-a85fb7914341&quot;/&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
The csrf field name is called <code>_csrf</code>.
<p/>
<b>Important:</b> When enabling csrf support then REST Assured <b>must always</b> make an additional request to the server in order to
be able to include in the csrf value which will slow down the tests.

@param fieldName The name of the input field
@return A new FormAuthConfig instance.
@see #withAutoDetectionOfCsrf()
Enable Cross - site request forgery ( csrf ) support when using form authentication by including the csrf value of the input field with the specified name . For example if the login page looks like this : <pre > &lt ; html&gt ; &lt ; head&gt ; &lt ; title&gt ; Login&lt ; / title&gt ; &lt ; / head&gt ; &lt ; body&gt ; &lt ; form action = &quot ; j_spring_security_check_with_csrf&quot ; method = &quot ; POST&quot ; &gt ; &lt ; table&gt ; &lt ; tr&gt ; &lt ; td&gt ; User : &amp ; nbsp ; &lt ; / td&gt ; &lt ; td&gt ; &lt ; input type = &quot ; text&quot ; name = &quot ; j_username&quot ; &gt ; &lt ; / td&gt ; &lt ; / tr&gt ; &lt ; tr&gt ; &lt ; td&gt ; Password : &lt ; / td&gt ; &lt ; td&gt ; &lt ; input type = &quot ; password&quot ; name = &quot ; j_password&quot ; &gt ; &lt ; / td&gt ; &lt ; / tr&gt ; &lt ; tr&gt ; &lt ; td colspan = &quot ; 2&quot ; &gt ; &lt ; input name = &quot ; submit&quot ; type = &quot ; submit&quot ; / &gt ; &lt ; / td&gt ; &lt ; / tr&gt ; &lt ; / table&gt ; &lt ; input type = &quot ; hidden&quot ; name = &quot ; _csrf&quot ; value = &quot ; 8adf2ea1 - b246 - 40aa - 8e13 - a85fb7914341&quot ; / &gt ; &lt ; / form&gt ; &lt ; / body&gt ; &lt ; / html&gt ; < / pre > The csrf field name is called <code > _csrf< / code > . <p / > <b > Important : < / b > When enabling csrf support then REST Assured <b > must always< / b > make an additional request to the server in order to be able to include in the csrf value which will slow down the tests .