Skip to content

Commit 8aaf1fe

Browse files
committed
feat: add username to logger
1 parent 8aae797 commit 8aaf1fe

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

app/middleware/app_logger/new.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,19 @@ func New() fiber.Handler {
5656
oidc_sub = c.Locals("oidc_sub").(string)
5757
}
5858

59+
username := ""
60+
if c.Locals("username") != nil {
61+
username = c.Locals("username").(string)
62+
}
63+
5964
logger.Sugar().WithOptions(
6065
zap.WithCaller(false),
6166
).Infow(
6267
"render engine request",
6368
"lmn_level", "request",
6469
"log_id", c.Locals("log_id").(string),
6570
"user_id", user_id,
71+
"username", username,
6672
"oidc_sub", oidc_sub,
6773
"route", c.Path(),
6874
"ip_address", c.IPs(),

app/middleware/auth/new.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func jwtValidation(c *fiber.Ctx, code string) error {
9191

9292
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
9393
c.Locals("user_id", claims["sub"])
94+
c.Locals("username", claims["username"])
9495
c.Locals("oidc_sub", claims["oidc_sub"])
9596
c.Locals("token", code)
9697
return c.Next()

0 commit comments

Comments
 (0)