Add HTTP middleware and logging cleanup to authserver
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
Description
Context
The authserver (pkg/authserver/) chi router in handler.go currently registers routes with zero middleware. This is foundational work that enables audit logging and telemetry.
Scope
HTTP middleware stack
The authserver's Routes() method needs a proper middleware chain:
- Panic recovery using existing
pkg/recovery.Middleware(every other HTTP server in the codebase has this) - Request ID injection (
chi/middleware.RequestID) for log correlation across audit and telemetry - Request timeout (default 30s) to protect against slow upstream IDP calls holding connections
- Request body size limiting as a safety net (the DCR handler has its own 64KB limit, but authorize/token endpoints have none)
Middleware ordering: recovery (outermost) → request ID → timeout → size limit → routes
Logging cleanup
Fix existing logging to follow project conventions (docs/logging.md):
- Downgrade all
Info-level success logs toDebug(silent-success principle):upstream/oauth2.go: 6 Info logs for provider creation, code exchange, token refreshhandlers/callback.go: "authorization successful, redirecting to client"handlers/user.go: "created new user with provider identity"
- Add structured fields (
client_id,session_id,user_id,upstream_provider) for log correlation
Acceptance criteria
- Panic recovery, request ID, timeout, and size limiting middleware applied to chi router
- All
Info-level success logs inpkg/authserver/downgraded toDebug - Structured fields added to log statements for correlation
- No sensitive data (tokens, codes) in any log or response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pkg/authserver/handler.go and inspect the existing recovery middleware and chi route setup, then read docs/logging.md. Review upstream/oauth2.go, handlers/callback.go, and handlers/user.go for the listed logs and correlation fields. Done means the required middleware order is applied, success logs are Debug-level with structured fields, and no sensitive data is logged or returned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend, observability, security
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100