# PASSWD — Password Protected Sections for DokuWiki

A syntax plugin that lets authors protect page sections with a password. Integrated with the [Captcha plugin](https://www.dokuwiki.org/plugin:captcha) to prevent brute-force attacks.

## Syntax

```
<passwd password="secret" prompt="Enter password:" btn="Unlock" error="Invalid password or captcha">
Protected content here. Supports all DokuWiki formatting.
</passwd>
```

All attributes except `password` are optional — defaults are set via the plugin configuration panel.

## How it works

1. **Rendering** — `syntax.php` outputs a password form with an empty captcha placeholder. No sensitive data enters the HTML, so the page cache stays clean.
2. **Captcha loading** — On DOM ready, `script.js` fetches a fresh captcha per block via `passwd_refresh_captcha`. Captcha tokens are never cached.
3. **Unlocking** — The user enters a password and submits the form. The AJAX handler `passwd_check` verifies the captcha first, then compares the password against the raw wiki text. On success it renders the hidden wikitext; on failure it returns a new captcha together with the error.

## Files

| File | Role |
|------|------|
| `syntax.php` | Lexer pattern and XHTML rendering |
| `action.php` | AJAX handlers for captcha refresh and password check |
| `script.js` | Client-side unlock logic |
| `conf/default.php` | Default prompt/button/error texts |
| `conf/metadata.php` | Config field metadata |

## Requirements

- DokuWiki 2024-02-06 "Kaos" or later
- [Captcha plugin](https://www.dokuwiki.org/plugin:captcha) (recommended; works without it too)
