Skip to content

Commit 72b6bd9

Browse files
authored
feat: migrate to Fiber v3 (#662)
Framework migration from Fiber v2 to v3, grounded in the official migration guide, rebased onto the post-#661 dependency state. **Mechanical**: import path `fiber/v3`; handlers take the `fiber.Ctx` interface (102 sites); `c.UserContext()` → `c.Context()` (36 sites); `c.Redirect(...)` → the v3 builder (27 sites); `c.BodyParser` → `c.Bind().Body` (2 sites); `app.Test` timeout args → `fiber.TestConfig`. **Semantic surfaces**: session store via `session.NewStore` with `Expiration` → `IdleTimeout`, and a pooled-session `Release()` added at all nine `store.Get` sites; CSRF config moves to `Extractor: extractors.FromForm` + `IdleTimeout`, and the removed `ContextKey` means the token is read via `csrf.TokenFromContext`; the removed filesystem middleware becomes the static middleware serving the embedded FS; `EnableTrustedProxyCheck`/`TrustedProxies` become `TrustProxy`/`TrustProxyConfig`. **Behavior changes inherited from v3, deliberate and documented**: bare redirects answer **303 See Other** instead of 302 Found; JSON responses carry `; charset=utf-8`; v3's CSRF middleware additionally enforces Origin/Referer/Sec-Fetch-Site consistency on unsafe methods (browser flows unaffected — e2e green; a non-browser client stripping Origin+Referer would newly 403); and v3's `c.IP()` now resolves the real peer right-to-left past the trusted proxies instead of echoing the raw client-controlled X-Forwarded-For — which **hardens** the login rate limiter (previously a forged XFF entry evaded blocking). **Adversarial review round** (tip 4c2d04a reviewed, fixes in 064f305): the four designated high-risk items were verified with source- and probe-level evidence — static asset resolution proven equivalent empirically (200 + correct bytes + `Cache-Control` for `/static/js/*`, `/static/app.css`, `/static/vendor/*`; traversal blocked), all nine session `Release()` sites checked against the v3.5.0 pool implementation (no double-release, Release-after-Destroy safe, login releases after Save, no CSRF/session aliasing), the CSRF render→extract→validate round trip is pinned by `bulk_csrf_test.go` and the e2e login-form test, and the trust-proxy change was analyzed as above. The review's one Required finding is fixed in 064f305: the doc/ops sweep — monitoring/deployment runbook health checks now accept 303 (they would have raised false CRITICAL alerts), the API docs' 302 statuses corrected, `internal/web/AGENTS.md` rewritten from v2 to v3 teachings, architecture/knowledge-base v2 references updated. Plus the review's test-gap nit: `TestApp_StaticAssetsServed` now pins the static mount, red-green verified (broken mount → fails with 303, restored → passes). **Round-2 verification** (fresh agent on 064f305): all seven fix claims verified PASS with module-source evidence; its two leftover findings of the same class — the package godoc in `internal/web/doc.go` (the pkg.go.dev surface), `docs/INDEX.md` and `cmd/AGENTS.md` still saying Fiber v2 — are fixed in ff72324 together with aligning the AGENTS.md CSRF example to the real config (`FromForm`, not `FromHeader`). A repo-wide grep now finds zero live Fiber v2 claims (dated plan archives excepted). Round 3 = that mechanical sweep plus this CI run: no findings remain. **Tests**: session stores via `NewStore`; the `fiber.Storage` mock gained the v3 context-aware methods; CSRF tests read the token via `TokenFromContext`; shifted test fixtures and one docs example password carry detect-secrets allowlist pragmas; markdownlint's pre-existing findings in the touched docs are fixed in the same pass. Verified locally under go1.27.0 at 064f305: `templ generate` + build, vet, golangci-lint (0 issues), `go test -race` (8 packages), `go mod verify` clean; fiber v2 has left the module graph entirely. _Assisted by claude-code:claude-fable-5 — [Session](https://claude.ai/code/session_01L7tF9XuJfAfFk4yuY5KfPK)_
2 parents ff65290 + 14f94ce commit 72b6bd9

53 files changed

Lines changed: 495 additions & 441 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
## Overview
66

7-
The `cmd/` directory contains the main entry point for the LDAP Manager application. This follows Go's standard project layout for executable binaries.
7+
The `cmd/` directory contains the main entry point for the LDAP Manager application. This follows Go's standard
8+
project layout for executable binaries.
89

910
- **Location**: `cmd/ldap-manager/main.go`
1011
- **Purpose**: CLI initialization, configuration parsing, server startup
11-
- **Framework**: Uses Fiber v2 web framework via `internal/web` package
12+
- **Framework**: Uses Fiber v3 web framework via `internal/web` package
1213

1314
## Setup & Environment
1415

docs/API_REFERENCE.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Authenticate user and create session.
5050

5151
**Form Data:**
5252

53-
```
53+
```text
5454
username=jdoe
5555
password=SecurePass123
5656
csrf_token=<generated-token>
@@ -60,10 +60,10 @@ csrf_token=<generated-token>
6060

6161
#### Success Response
6262

63-
**Code:** `302 Found`
63+
**Code:** `303 See Other`
6464
**Headers:**
6565

66-
```
66+
```text
6767
Location: /
6868
Set-Cookie: session_id=...; HttpOnly; Secure; SameSite=Strict
6969
```
@@ -110,10 +110,10 @@ Terminate user session.
110110

111111
#### Success Response
112112

113-
**Code:** `302 Found`
113+
**Code:** `303 See Other`
114114
**Headers:**
115115

116-
```
116+
```text
117117
Location: /login
118118
Set-Cookie: session_id=; Expires=Thu, 01 Jan 1970 00:00:00 GMT
119119
```
@@ -340,7 +340,7 @@ Dashboard/home page (redirects to users list).
340340
**Content-Type:** `text/html`
341341
**Headers:**
342342

343-
```
343+
```text
344344
X-Cache: HIT | MISS
345345
```
346346

@@ -375,11 +375,11 @@ List all LDAP users.
375375
**Content-Type:** `text/html`
376376
**Headers:**
377377

378-
```
378+
```text
379379
X-Cache: HIT | MISS
380380
```
381381

382-
**Rendered HTML with user table**
382+
#### Rendered HTML with user table
383383

384384
#### Notes
385385

@@ -456,7 +456,7 @@ Modify user attributes.
456456

457457
**Form Data:**
458458

459-
```
459+
```text
460460
csrf_token=<token>
461461
mail=newemail@example.com
462462
telephoneNumber=+1-555-0123
@@ -465,10 +465,10 @@ description=Updated description
465465

466466
#### Success Response
467467

468-
**Code:** `302 Found`
468+
**Code:** `303 See Other`
469469
**Headers:**
470470

471-
```
471+
```text
472472
Location: /users/:userDN
473473
Set-Cookie: flash_message=User updated successfully
474474
```
@@ -576,18 +576,18 @@ Modify group (add/remove members).
576576

577577
**Form Data:**
578578

579-
```
579+
```text
580580
csrf_token=<token>
581581
action=add_member | remove_member
582582
member_dn=cn=jdoe,ou=users,dc=example,dc=com
583583
```
584584

585585
#### Success Response
586586

587-
**Code:** `302 Found`
587+
**Code:** `303 See Other`
588588
**Headers:**
589589

590-
```
590+
```text
591591
Location: /groups/:groupDN
592592
Set-Cookie: flash_message=Member added successfully
593593
```
@@ -616,7 +616,7 @@ List all computer accounts (Active Directory).
616616
**Code:** `200 OK`
617617
**Content-Type:** `text/html`
618618

619-
**Rendered HTML with computer account table**
619+
#### Rendered HTML with computer account table
620620

621621
#### Notes
622622

@@ -640,7 +640,7 @@ Display computer account details.
640640
**Code:** `200 OK`
641641
**Content-Type:** `text/html`
642642

643-
**Rendered HTML with computer attributes**
643+
#### Rendered HTML with computer attributes
644644

645645
---
646646

@@ -764,4 +764,4 @@ curl -b cookies.txt -X POST \
764764

765765
---
766766

767-
_Last Updated: 2025-09-30 | Version: 1.0.8_
767+
Last Updated: 2025-09-30 | Version: 1.0.8

docs/INDEX.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ Comprehensive technical analysis and session documentation (21 reports):
135135
| [**Frontend Analysis**](../claudedocs/comprehensive-frontend-analysis.md) | Complete frontend architecture review | 2025-09-30 |
136136
| [**CSS Analysis**](../claudedocs/css-analysis.md) | CSS structure and optimization opportunities | 2025-09-30 |
137137

138-
**Purpose:** These reports provide deep technical insights for developers, architects, and operations teams. Generated during development sessions for knowledge preservation and decision documentation.
138+
**Purpose:** These reports provide deep technical insights for developers, architects, and operations teams. Generated
139+
during development sessions for knowledge preservation and decision documentation.
139140

140141
---
141142

@@ -250,7 +251,7 @@ LDAP_POOL_HEALTH_CHECK_INTERVAL=30s
250251

251252
## 🏗️ Project Structure
252253

253-
```
254+
```text
254255
ldap-manager/
255256
├── cmd/ldap-manager/ # Application entry point
256257
├── internal/ # Core application code
@@ -337,27 +338,28 @@ Current project health indicators:
337338

338339
### Official Documentation
339340

340-
- **Go:** https://go.dev/doc/
341-
- **Fiber v2:** https://docs.gofiber.io/
342-
- **Templ:** https://templ.guide/
343-
- **TailwindCSS:** https://tailwindcss.com/docs
344-
- **go-ldap:** https://pkg.go.dev/github.com/go-ldap/ldap/v3
341+
- **Go:** <https://go.dev/doc/>
342+
- **Fiber v3:** <https://docs.gofiber.io/>
343+
- **Templ:** <https://templ.guide/>
344+
- **TailwindCSS:** <https://tailwindcss.com/docs>
345+
- **go-ldap:** <https://pkg.go.dev/github.com/go-ldap/ldap/v3>
345346

346347
### Related Projects
347348

348349
- **simple-ldap-go v1.5.0:** Custom LDAP wrapper with indexed cache
349-
- **Our Contribution:** [PR #45](https://github.com/netresearch/simple-ldap-go/pull/45) - Multi-key indexed cache (287x improvement)
350+
- **Our Contribution:** [PR #45](https://github.com/netresearch/simple-ldap-go/pull/45) - Multi-key indexed cache
351+
(287x improvement)
350352
- **Status:** Merged and released in v1.5.0
351-
- **GitHub:** https://github.com/netresearch/simple-ldap-go
353+
- **GitHub:** <https://github.com/netresearch/simple-ldap-go>
352354
- **BBolt:** Embedded key-value database for sessions
353355
- **Use Case:** Persistent session storage for development and production
354-
- **GitHub:** https://github.com/etcd-io/bbolt
356+
- **GitHub:** <https://github.com/etcd-io/bbolt>
355357

356358
---
357359

358360
## 🆘 Getting Help
359361

360-
### Documentation Not Found?
362+
### Documentation Not Found
361363

362364
1. **Check AGENTS.md:** AI guidelines may have what you need
363365
2. **Search codebase:** `grep -r "pattern" internal/`
@@ -450,6 +452,7 @@ Potential future enhancements (not committed):
450452

451453
---
452454

453-
_This index is maintained automatically and manually. Last comprehensive update: 2025-09-30 (Enhanced with PR #267 details, claudedocs integration, and API module reference)_
455+
This index is maintained automatically and manually. Last comprehensive update: 2025-09-30 (Enhanced with PR #267
456+
details, claudedocs integration, and API module reference)
454457

455458
**📌 Bookmark this page** - it's your hub for all LDAP Manager documentation.

docs/KNOWLEDGE_BASE.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ Use Ctrl+F or Command+F to search this document for:
3434

3535
### By Persona
3636

37-
**👤 End Users (Administrators)**
37+
#### 👤 End Users (Administrators)
3838

3939
1. [Installation Guide](user-guide/installation.md) - Get started
4040
2. [Configuration Reference](user-guide/configuration.md) - Configure LDAP connection
4141
3. [API Documentation](user-guide/api.md) - Integrate with other systems
4242
4. [Implementation Examples](user-guide/implementation-examples.md) - Real-world scenarios
4343

44-
**👨‍💻 Developers**
44+
#### 👨‍💻 Developers
4545

4646
1. [Development Setup](development/setup.md) - Setup local environment
4747
2. [AGENTS.md](../AGENTS.md) - AI-assisted coding guidelines
4848
3. [Architecture Overview](development/architecture.md) - Understand system design
4949
4. [Contributing Guidelines](development/contributing.md) - Submit changes
5050
5. [Go Documentation](development/go-doc-reference.md) - Package API reference
5151

52-
**⚙️ Operations / DevOps**
52+
#### ⚙️ Operations / DevOps
5353

5454
1. [Deployment Guide](operations/deployment.md) - Deploy to production
5555
2. [Monitoring & Troubleshooting](operations/monitoring.md) - Operational procedures
@@ -279,9 +279,9 @@ make docker-test # Run tests in container
279279

280280
### Component Map
281281

282-
```
282+
```text
283283
┌─────────────────────────────────────────────┐
284-
│ HTTP Layer (Fiber v2) │
284+
│ HTTP Layer (Fiber v3) │
285285
│ ├─ server.go - App initialization │
286286
│ ├─ auth.go - Authentication │
287287
│ ├─ users.go, groups.go, computers.go │
@@ -380,7 +380,7 @@ LDAP_POOL_ACQUIRE_TIMEOUT=5s # Lower acquisition timeout
380380

381381
### Common Issues
382382

383-
**Build Fails**
383+
#### Build Fails
384384

385385
```bash
386386
# Solution
@@ -389,7 +389,7 @@ go mod tidy
389389
pnpm install
390390
```
391391

392-
**Tests Fail**
392+
#### Tests Fail
393393

394394
```bash
395395
# Check LDAP server is running
@@ -398,7 +398,7 @@ docker compose --profile dev up openldap -d
398398
go test -v ./...
399399
```
400400

401-
**Can't Connect to LDAP**
401+
#### Can't Connect to LDAP
402402

403403
```bash
404404
# Verify configuration
@@ -407,7 +407,7 @@ cat .env | grep LDAP_
407407
ldapsearch -H ldaps://dc1.example.com:636 -D "cn=readonly,DC=example,DC=com" -w password -b "DC=example,DC=com"
408408
```
409409

410-
**Performance Issues**
410+
#### Performance Issues
411411

412412
```bash
413413
# Check cache hit rates
@@ -460,29 +460,31 @@ curl http://localhost:3000/debug/ldap-pool
460460

461461
### Official Documentation
462462

463-
- **Go Language:** https://go.dev/doc/ ([Tutorial](https://go.dev/tour/), [Effective Go](https://go.dev/doc/effective_go))
464-
- **Fiber v2:** https://docs.gofiber.io/ ([API](https://docs.gofiber.io/api/fiber), [Middleware](https://docs.gofiber.io/api/middleware))
465-
- **Templ:** https://templ.guide/ ([Components](https://templ.guide/syntax-and-usage/components), [IDE Support](https://templ.guide/commands-and-tools/ide-support))
466-
- **TailwindCSS:** https://tailwindcss.com/docs ([Configuration](https://tailwindcss.com/docs/configuration), [Utility Classes](https://tailwindcss.com/docs/utility-first))
467-
- **go-ldap/ldap:** https://pkg.go.dev/github.com/go-ldap/ldap/v3
463+
- **Go Language:** <https://go.dev/doc/> ([Tutorial](https://go.dev/tour/), [Effective Go](https://go.dev/doc/effective_go))
464+
- **Fiber v3:** <https://docs.gofiber.io/> ([API](https://docs.gofiber.io/api/fiber), [Middleware](https://docs.gofiber.io/api/middleware))
465+
- **Templ:** <https://templ.guide/> ([Components](https://templ.guide/syntax-and-usage/components), [IDE Support](https://templ.guide/commands-and-tools/ide-support))
466+
- **TailwindCSS:** <https://tailwindcss.com/docs> ([Configuration](https://tailwindcss.com/docs/configuration),
467+
[Utility Classes](https://tailwindcss.com/docs/utility-first))
468+
- **go-ldap/ldap:** <https://pkg.go.dev/github.com/go-ldap/ldap/v3>
468469

469470
### Project Resources
470471

471-
- **simple-ldap-go v1.5.0:** https://github.com/netresearch/simple-ldap-go
472+
- **simple-ldap-go v1.5.0:** <https://github.com/netresearch/simple-ldap-go>
472473
- Our Contribution: [PR #45 - Multi-key Indexed Cache](https://github.com/netresearch/simple-ldap-go/pull/45)
473-
- **BBolt:** https://github.com/etcd-io/bbolt ([Getting Started](https://github.com/etcd-io/bbolt#getting-started))
474+
- **BBolt:** <https://github.com/etcd-io/bbolt> ([Getting Started](https://github.com/etcd-io/bbolt#getting-started))
474475

475476
### Learning Resources
476477

477-
- **Go Testing:** https://go.dev/doc/tutorial/add-a-test
478-
- **LDAP Basics:** https://ldap.com/learn-about-ldap/
479-
- **Active Directory:** https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/
478+
- **Go Testing:** <https://go.dev/doc/tutorial/add-a-test>
479+
- **LDAP Basics:** <https://ldap.com/learn-about-ldap/>
480+
- **Active Directory:** <https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/>
480481

481482
---
482483

483484
## 📝 Keywords for Search
484485

485-
**Features:** Authentication, Authorization, Caching, Connection Pooling, Health Checks, LDAP, Active Directory, Session Management, Template Rendering, Static Assets
486+
**Features:** Authentication, Authorization, Caching, Connection Pooling, Health Checks, LDAP, Active Directory,
487+
Session Management, Template Rendering, Static Assets
486488

487489
**Technologies:** Go, Golang, Fiber, Templ, TailwindCSS, BBolt, LDAP, Active Directory, Docker, pnpm
488490

@@ -498,4 +500,4 @@ curl http://localhost:3000/debug/ldap-pool
498500

499501
---
500502

501-
_Last updated: 2025-09-30 | Comprehensive knowledge base with search aids and cross-references_
503+
Last updated: 2025-09-30 | Comprehensive knowledge base with search aids and cross-references

docs/development/architecture.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Architecture Overview
22

3-
Comprehensive technical architecture documentation for LDAP Manager, covering system design, component interactions, and implementation patterns.
3+
Comprehensive technical architecture documentation for LDAP Manager, covering system design, component interactions,
4+
and implementation patterns.
45

56
## System Architecture
67

78
![LDAP Manager Architecture](../assets/architecture.png)
89

910
LDAP Manager follows a layered architecture pattern with clear separation of concerns:
1011

11-
```
12+
```text
1213
┌─────────────────────────────────────────────────┐
1314
│ Web Layer │
14-
│ • HTTP Handlers & Routing (Fiber v2) │
15+
│ • HTTP Handlers & Routing (Fiber v3) │
1516
│ • Session Management │
1617
│ • Template Rendering (templ) │
1718
│ • Static Asset Serving │
@@ -644,4 +645,5 @@ CMD ["./ldap-manager"]
644645
- Memory cache size optimization
645646
- Resource limits and requests
646647

647-
This architecture provides a solid foundation for a secure, performant, and maintainable LDAP directory management system. The modular design allows for easy testing, enhancement, and scaling as requirements evolve.
648+
This architecture provides a solid foundation for a secure, performant, and maintainable LDAP directory management
649+
system. The modular design allows for easy testing, enhancement, and scaling as requirements evolve.

docs/operations/deployment.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Deployment Guide
22

3-
Comprehensive guide for deploying LDAP Manager in production environments, covering various deployment strategies, configurations, and operational best practices.
3+
Comprehensive guide for deploying LDAP Manager in production environments, covering various deployment strategies,
4+
configurations, and operational best practices.
45

56
## Overview
67

@@ -115,7 +116,7 @@ services:
115116
116117
```bash
117118
# Set password via environment
118-
export LDAP_PASSWORD="your_secure_password"
119+
export LDAP_PASSWORD="your_secure_password" # pragma: allowlist secret
119120

120121
# Deploy
121122
docker compose up -d
@@ -750,7 +751,7 @@ RESPONSE=$(curl -s -o /dev/null -w "%{http_code}:%{time_total}" "$HEALTH_URL")
750751
STATUS_CODE=$(echo $RESPONSE | cut -d: -f1)
751752
RESPONSE_TIME=$(echo $RESPONSE | cut -d: -f2)
752753

753-
if [ "$STATUS_CODE" = "200" ] || [ "$STATUS_CODE" = "302" ]; then
754+
if [ "$STATUS_CODE" = "200" ] || [ "$STATUS_CODE" = "303" ]; then
754755
echo "OK - LDAP Manager healthy (${RESPONSE_TIME}s)"
755756
exit 0
756757
else
@@ -896,4 +897,5 @@ sudo cp /opt/ldap-manager/ldap-manager.backup /opt/ldap-manager/ldap-manager
896897
sudo systemctl start ldap-manager
897898
```
898899

899-
This deployment guide provides production-ready configurations for various environments. Choose the deployment method that best fits your infrastructure and security requirements.
900+
This deployment guide provides production-ready configurations for various environments. Choose the deployment method
901+
that best fits your infrastructure and security requirements.

0 commit comments

Comments
 (0)