xref: /plugin/passwd/README.md (revision eb872c2a652d2b4294f9c5ebca2ba18675c61627)
1*eb872c2aStomLin1998567# PASSWD — Password Protected Sections for DokuWiki
2*eb872c2aStomLin1998567
3*eb872c2aStomLin1998567A 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.
4*eb872c2aStomLin1998567
5*eb872c2aStomLin1998567## Syntax
6*eb872c2aStomLin1998567
7*eb872c2aStomLin1998567```
8*eb872c2aStomLin1998567<passwd password="secret" prompt="Enter password:" btn="Unlock" error="Invalid password or captcha">
9*eb872c2aStomLin1998567Protected content here. Supports all DokuWiki formatting.
10*eb872c2aStomLin1998567</passwd>
11*eb872c2aStomLin1998567```
12*eb872c2aStomLin1998567
13*eb872c2aStomLin1998567All attributes except `password` are optional — defaults are set via the plugin configuration panel.
14*eb872c2aStomLin1998567
15*eb872c2aStomLin1998567## How it works
16*eb872c2aStomLin1998567
17*eb872c2aStomLin19985671. **Rendering** — `syntax.php` outputs a password form with an empty captcha placeholder. No sensitive data enters the HTML, so the page cache stays clean.
18*eb872c2aStomLin19985672. **Captcha loading** — On DOM ready, `script.js` fetches a fresh captcha per block via `passwd_refresh_captcha`. Captcha tokens are never cached.
19*eb872c2aStomLin19985673. **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.
20*eb872c2aStomLin1998567
21*eb872c2aStomLin1998567## Files
22*eb872c2aStomLin1998567
23*eb872c2aStomLin1998567| File | Role |
24*eb872c2aStomLin1998567|------|------|
25*eb872c2aStomLin1998567| `syntax.php` | Lexer pattern and XHTML rendering |
26*eb872c2aStomLin1998567| `action.php` | AJAX handlers for captcha refresh and password check |
27*eb872c2aStomLin1998567| `script.js` | Client-side unlock logic |
28*eb872c2aStomLin1998567| `conf/default.php` | Default prompt/button/error texts |
29*eb872c2aStomLin1998567| `conf/metadata.php` | Config field metadata |
30*eb872c2aStomLin1998567
31*eb872c2aStomLin1998567## Requirements
32*eb872c2aStomLin1998567
33*eb872c2aStomLin1998567- DokuWiki 2024-02-06 "Kaos" or later
34*eb872c2aStomLin1998567- [Captcha plugin](https://www.dokuwiki.org/plugin:captcha) (recommended; works without it too)
35