Skip to content

Commit 8aae797

Browse files
committed
feat: add OIDC subject handling to user model and logging middleware
1 parent b81caac commit 8aae797

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

app/middleware/app_logger/new.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ func New() fiber.Handler {
5151
user_id = c.Locals("user_id").(string)
5252
}
5353

54+
oidc_sub := ""
55+
if c.Locals("oidc_sub") != nil {
56+
oidc_sub = c.Locals("oidc_sub").(string)
57+
}
58+
5459
logger.Sugar().WithOptions(
5560
zap.WithCaller(false),
5661
).Infow(
5762
"render engine request",
5863
"lmn_level", "request",
5964
"log_id", c.Locals("log_id").(string),
6065
"user_id", user_id,
66+
"oidc_sub", oidc_sub,
6167
"route", c.Path(),
6268
"ip_address", c.IPs(),
6369
"request_details", formData,

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("oidc_sub", claims["oidc_sub"])
9495
c.Locals("token", code)
9596
return c.Next()
9697
} else {

app/models/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type User struct {
1515
ForceChange bool `json:"-" pg:"forceChange"`
1616
ObjectGUID string `json:"objectguid" pg:"objectguid"`
1717
AuthType string `json:"auth_type"`
18+
OidcSub string `json:"oidc_sub"`
1819
}
1920

2021
func (User) TableName() string {

0 commit comments

Comments
 (0)