Skip to content

Commit

Permalink
fix: accesslog handler updated to include information about authentic…
Browse files Browse the repository at this point in the history
…ated subject if present (#162)
  • Loading branch information
dadrus authored Aug 12, 2022
1 parent 5a1125b commit 3e286db
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions internal/fiber/middleware/accesslog/accesslog_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,21 @@ func createAccessLogFinalizationEvent(c *fiber.Ctx, accessLogger zerolog.Logger,
Int("_http_status_code", c.Response().StatusCode()).
Int64("_tx_duration_ms", duration.Milliseconds())

if err != nil {
event = event.Err(err)
}
switch {
case err != nil:
if len(alc.subject) != 0 {
event = event.Str("_subject", alc.subject)
}

event = event.Err(err).Bool("_access_granted", false)
case alc.err != nil:
if len(alc.subject) != 0 {
event = event.Str("_subject", alc.subject)
}

if alc.err != nil {
event = event.Err(alc.err).Bool("_access_granted", false)
} else if len(alc.subject) != 0 {
event.Str("_subject", alc.subject).Bool("_access_granted", true)
default:
event = event.Str("_subject", alc.subject).Bool("_access_granted", true)
}

return event
Expand Down

0 comments on commit 3e286db

Please sign in to comment.