# CSRF Configuration

The `csrf` plugin protects routes and services from cross-site request forgery by validating a signed token in matching request headers and cookies.<!-- --> <!-- -->Configuration covers plugin parameters.

## Parameters[​](#parameters "Direct link to Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) for configuration options available to all plugins.

* key

  string

  required

  ***

  Secret used to sign CSRF tokens. Use a high-entropy value and keep it private.

  The field is marked for encrypted storage when gateway data encryption is enabled. Protect the plaintext value in declarative files and secret-delivery workflows.

* expires

  integer

  default: `7200`

  ***

  Token validity period in seconds. Setting `0` skips server-side age validation but sets the cookie expiration to its issuance time, so cookie clients may discard it immediately.

* name

  string

  default: `apisix-csrf-token`

  ***

  Name used for both the CSRF token cookie and the request header that carries the submitted token.
