Skip to content

Commit

Permalink
Add UserName & ClientId to the security log.
Browse files Browse the repository at this point in the history
Resolve #5120
  • Loading branch information
maliming committed Aug 20, 2020
1 parent 8822c10 commit b35cead
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public AbpResourceOwnerPasswordValidator(
[UnitOfWork]
public virtual async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
{
var clientId = context.Request?.Client?.ClientId;
using var scope = ServiceScopeFactory.CreateScope();

await ReplaceEmailToUsernameOfInputIfNeeds(context);
Expand Down Expand Up @@ -91,7 +92,8 @@ await IdentitySecurityLogManager.SaveAsync(
{
Identity = IdentityServerSecurityLogIdentityConsts.IdentityServer,
Action = IdentityServerSecurityLogActionConsts.LoginSucceeded,
UserName = context.UserName
UserName = context.UserName,
ClientId = clientId
}
);
}
Expand Down Expand Up @@ -154,7 +156,8 @@ await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
{
Identity = IdentityServerSecurityLogIdentityConsts.IdentityServer,
Action = result.ToIdentitySecurityLogAction(),
UserName = context.UserName
UserName = context.UserName,
ClientId = clientId
});
}
else
Expand All @@ -166,7 +169,9 @@ await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext()
{
Identity = IdentityServerSecurityLogIdentityConsts.IdentityServer,
Action = IdentityServerSecurityLogActionConsts.LoginInvalidUserName
Action = IdentityServerSecurityLogActionConsts.LoginInvalidUserName,
UserName = context.UserName,
ClientId = clientId
});
}

Expand Down

0 comments on commit b35cead

Please sign in to comment.