Skip to content

Commit

Permalink
chore: gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
ychung-mot committed Sep 13, 2024
1 parent 4f3ff84 commit 41cb7f5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/StrDss.Api/Authentication/ApsJwtBearerEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public ApsJwtBearerEvents(ICurrentUser currentUser, IUserService userService, IR
_memoryCache = memoryCache;
}

public override Task AuthenticationFailed(AuthenticationFailedContext context)
{
var username = context.HttpContext.User?.Identity?.Name ?? "Unknown";
var ipAddress = context.HttpContext.Connection.RemoteIpAddress;
var ip = ipAddress == null ? "Unknown" : ipAddress.ToString();

_logger.LogInformation($"[AUTH] Authentication failed for user '{username}' from IP address '{ip}'.");

return base.AuthenticationFailed(context);
}

public override async Task TokenValidated(TokenValidatedContext context)
{
_currentUser.LoadApsSession(context!.Principal!);
Expand Down

0 comments on commit 41cb7f5

Please sign in to comment.