# Deployment (laravel-rust-captcha)

> Set the exceptions for both input normalizers in the application's final with_middleware callback. Include the fields other providers need alongside the…

- Package: laravel-rust-captcha (Laravel for Rust, alpha), crates: `laravel-rust-captcha`
- Maintenance: active; Latest release: 0.1.0 (2026-12-04); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-captcha), [crates.io](https://crates.io/crates/laravel-rust-captcha/0.1.0), [docs.rs](https://docs.rs/laravel-rust-captcha/0.1.0), [Changelog](https://oss.bowerbird.si/captcha/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-captcha/blob/57c677c77d6c928790e0acaf24e0b3f0ff06f29c/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-captcha/blob/57c677c77d6c928790e0acaf24e0b3f0ff06f29c/SECURITY.md)
- Based on: [mews/captcha](https://github.com/mewebstudio/captcha): The captcha package this ports: profiles, config keys, routes and validation, following version 3.5.1. Its backgrounds and fonts ship with their own licences.
- PHP parity: full (54 covered, 33 diverged, 0 planned of 87 abilities; 44 fixtures; follows mews/captcha 3.5.1; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/captcha/docs/deployment/
- Source: https://github.com/bowerbird-si/laravel-rust-captcha/blob/57c677c77d6c928790e0acaf24e0b3f0ff06f29c/docs/deployment.md

## Input middleware

Set the exceptions for both input normalizers in the application's final `with_middleware` callback.
Include the fields other providers need alongside the captcha's configured answer and key fields.

```rust
use laravel_rust_captcha::CaptchaServiceProvider;

Application::configure().with_middleware(|middleware, config| {
    CaptchaServiceProvider::configure_input(middleware, config, &["password_confirmation"]);
});
```

If trimming and empty-to-null conversion need different app exceptions, supply their lists
separately with `TrimStrings::except` and `ConvertEmptyStringsToNull::except`. Include the captcha
fields in both. The app checks the global replacements at boot. Apply the same exceptions to any
additional normalizers you install in other parts of the stack.

## The challenge store

Challenges live in a cache store (`CAPTCHA_STORE`, or the default store). Every process that serves your
app must see the same store, or an answer can be checked against a process that never issued it, and
"one pass per challenge" can't hold.

| Store | In production |
| --- | --- |
| `redis` | Recommended. Requires `CAPTCHA_TRUST_STORE=true`. |
| `database` (Postgres, MySQL) | Requires `CAPTCHA_TRUST_STORE=true`. Enable the captcha crate's `database` feature and use a writer-only connection. Checks use another pooled connection, outside your transaction. |
| `database` (SQLite) | Requires `CAPTCHA_TRUST_STORE=true`. Enable `database` if the app already enables Laravel's SQLite driver, or use `database-sqlite` to enable both. Give the captcha store a separate file. Boot compares the effective filenames, including across connection aliases. |
| Custom | Requires `CAPTCHA_TRUST_STORE=true`. The driver must provide atomic `add`, `increment`, `decrement` and `forget`. `forget` must report whether it removed a live value. |
| `memory` | Refused, unless `CAPTCHA_SINGLE_PROCESS=true`: each process has its own memory. |
| `failover` | Refused: it can answer different operations from different stores. |
| `discard` | Refused: it keeps nothing, so every check would fail. |

Laravel for Rust 0.2 lets an app replace a driver factory under a built-in name. Verify that the
resolved backend is shared and provides the atomic operations above before setting
`CAPTCHA_TRUST_STORE=true` for any production shared store. The app stops at boot if the store is refused.

## Transactions

The captcha's reads and writes never join a database transaction you have open. A check inside a
transaction that rolls back still counts the attempt, so a failing form can't hand out free guesses.

## Limits

| Limit | Default | Setting |
| --- | --- | --- |
| Images per client per clock minute (both routes and `issue`) | 30 | `CAPTCHA_THROTTLE` |
| Wrong answers per client and profile per clock minute | 10 | `CAPTCHA_FAILURE_LIMIT` |
| Images drawn at once | CPU count | `CAPTCHA_MAX_RENDERS` |
| Wait for a free renderer | 1 second, then 503 | |
| Wait for the entire check | 2 seconds, then the check fails closed | |

Both limits use the challenge store. Each fixed window admits at most N image requests per client
per clock minute across profiles, and at most N wrong answers per client and profile per clock
minute. Keep clocks synchronized across application processes that share the store.

## Caching and proxies

Both routes send `Cache-Control: no-store`. Don't cache them in a CDN: every request must reach the app
to issue a new challenge.

## Key rotation

Answers are checked against the current `APP_KEY` and every key in `APP_PREVIOUS_KEYS`, so rotating the
key doesn't break challenges that are open.
