| 1 |
# Agent instructions |
| 2 |
|
| 3 |
Follow [`CONTRIBUTING.md`](CONTRIBUTING.md) for all changes. See |
| 4 |
[`DEVELOPER.md`](DEVELOPER.md) for the architecture and `docs/` for user-facing |
| 5 |
configuration and behavior. |
| 6 |
|
| 7 |
## Pull request labels |
| 8 |
|
| 9 |
Before merging, apply at least one label from [`.github/release.yml`](.github/release.yml): |
| 10 |
|
| 11 |
- `๐ฅ breaking-change`: breaking changes |
| 12 |
- `โจ enhancement`: user-visible functionality |
| 13 |
- `๐ bug`: fixes |
| 14 |
- `๐ ๏ธ dependencies`: dependency updates |
| 15 |
- `๐ docs`: documentation |
| 16 |
- `chore`: internal performance work, tests, CI, or maintenance |
| 17 |
|
| 18 |
Add `๐ฅ breaking-change` alongside any other applicable label. Labeling is an |
| 19 |
AI-agent-only operation; do not tell external contributors to apply labels. |
| 20 |
|
| 21 |
## Program overview |
| 22 |
|
| 23 |
This Go application bridges OpenVPN's webauth protocol with OIDC providers. It |
| 24 |
communicates with the OpenVPN management interface and serves the browser-based |
| 25 |
authentication flow over HTTP. |
| 26 |
|
| 27 |
## Client-visible error classification |
| 28 |
|
| 29 |
Preserve broad failure classes without exposing implementation details: |
| 30 |
|
| 31 |
- `client rejected`: authentication or authorization failures |
| 32 |
- `internal error`: infrastructure or internal processing failures |
| 33 |
|
| 34 |
Log the technical error. Browser error pages must show an opaque, log-correlated |
| 35 |
error ID. Never classify errors by matching message strings; if upstream provides |
| 36 |
no structured distinction, keep the generic classification. See |
| 37 |
[issue #1121](https://github.com/jkroepke/openvpn-auth-oauth2/issues/1121). |
| 38 |
|
| 39 |
## Plugin cgo pointer checks |
| 40 |
|
| 41 |
Compile all tests with `GOEXPERIMENT=cgocheck2`; the `Makefile` and CI test job |
| 42 |
already set it. |
| 43 |
Do not try to enable it at runtime with `GODEBUG`, `//go:debug`, or `t.Setenv`. |
| 44 |
|
| 45 |
## Encrypted-state format migrations |
| 46 |
|
| 47 |
Only client-held OAuth state and profile-selector ciphertext can cross an |
| 48 |
executable upgrade, and they remain active for at most five minutes. Refresh-token |
| 49 |
ciphertext is process-local, is lost on restart, and survives only in-process |
| 50 |
configuration reloads. Do not add refresh-token migration or background |
| 51 |
re-encryption solely for a format change. |
| 52 |
|
| 53 |
Switch formats directly if affected users may retry authentication. Otherwise, |
| 54 |
temporarily read legacy ciphertext while writing the new version. Legacy reads |
| 55 |
are needed only until five minutes after the last old instance stops issuing |
| 56 |
ciphertext. For rolling deployments, stage the switch because old instances |
| 57 |
cannot read the new format. |
| 58 |
|
| 59 |
## OpenVPN management command size |
| 60 |
|
| 61 |
For `client-pending-auth` URL validation: |
| 62 |
|
| 63 |
- OpenVPN accepts at most 1023 command-body bytes before the terminating LF. |
| 64 |
This is a byte limit. OpenVPN discards this project's CR, so CR does not reduce |
| 65 |
the allowance. |
| 66 |
- For `client-pending-auth <CID> <KID> "WEB_AUTH::<URL>" <TIMEOUT>`, the body is |
| 67 |
`35 + digits(CID) + digits(KID) + bytes(URL) + digits(TIMEOUT)` bytes. |
| 68 |
- Therefore, the maximum URL size is |
| 69 |
`988 - digits(CID) - digits(KID) - digits(TIMEOUT)` bytes. Assuming a CID of |
| 70 |
at most five digits, a one-digit KID, and timeout `300`, the URL may contain at |
| 71 |
most 979 bytes. Quoting or escaping consumes more. |
| 72 |
- Do not confuse a conservative project policy with OpenVPN's actual limit. |
| 73 |
- OpenVPN's later TLS `EXTRA` limit is 1013 parsed bytes; the 1023-byte management |
| 74 |
command limit is tighter for this template. |
| 75 |
|
| 76 |
The source evidence is pinned to OpenVPN commit |
| 77 |
[`a6537f7549f70f16bb2efd5c0683e0e94a236f0c`](https://github.com/OpenVPN/openvpn/commit/a6537f7549f70f16bb2efd5c0683e0e94a236f0c). |