aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/main.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-20 21:58:17 +0900
committernsfisis <nsfisis@gmail.com>2026-02-20 21:58:17 +0900
commit26ead17e4c3682a93f64cca646b291b7ce6b195d (patch)
tree1db444afeba2e65f4217871a20a36b96bb432462 /backend/main.go
parent85b7a14913c05b88b720fc546eaca5575ffe53fd (diff)
downloadphperkaigi-2026-albatross-26ead17e4c3682a93f64cca646b291b7ce6b195d.tar.gz
phperkaigi-2026-albatross-26ead17e4c3682a93f64cca646b291b7ce6b195d.tar.zst
phperkaigi-2026-albatross-26ead17e4c3682a93f64cca646b291b7ce6b195d.zip
feat(auth): add structured logging for login success and failure
Add ClientIPMiddleware to extract client IP into context.Context, enabling structured log output with username, IP, and failure reason for login attempts. Change failed login log level from Error to Warn as authentication failures are expected events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend/main.go')
-rw-r--r--backend/main.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/backend/main.go b/backend/main.go
index 3ea4493..e74a62f 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -99,6 +99,7 @@ func main() {
loginRL := ratelimit.NewIPRateLimiter(rate.Every(time.Minute/5), 5)
apiGroup := e.Group(conf.BasePath + "api")
+ apiGroup.Use(api.ClientIPMiddleware())
apiGroup.Use(ratelimit.LoginRateLimitMiddleware(loginRL))
apiGroup.Use(api.SessionCookieMiddleware(queries))
apiGroup.Use(oapimiddleware.OapiRequestValidator(openAPISpec))