-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce security log. #4675
Introduce security log. #4675
Conversation
securityLog.UserName = eventData.UserName; | ||
} | ||
|
||
if (securityLog.ClientId.IsNullOrWhiteSpace()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be vice verse? I mean a filled eventData.ClientId should override the securityLog.ClientId. What do you think?
I didn't think much, but it seems like that. If that's true, no problem.
return; | ||
} | ||
|
||
using (var uow = UnitOfWorkManager.Begin(requiresNew: true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be a "non transactional" UOW since it contains only one insert. It will reduce the dedlock probability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Begin(requiresNew: true)
is extension method.
abp/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs
Lines 10 to 16 in ae8095d
public static IUnitOfWork Begin( | |
[NotNull] this IUnitOfWorkManager unitOfWorkManager, | |
bool requiresNew = false, | |
bool isTransactional = false, | |
IsolationLevel? isolationLevel = null, | |
int? timeout = null) | |
{ |
I accepted the PR. Added two notes, so you can check and fix theme if necessary. But the essentional design question is that: Why we are using event bus to save a security log. We should be able to directly use the ISecurityLogManager. Using evenbus is not a good way if we can use direct method calls. Please re-consider this design and drop using the event bus. |
Open a new PR for the above comment. #4810 |
How to write security logs.
You can inject and use
ISecurityLogManager
to write security logs. It will create a log object by default and fill in some common values, such as CreationTime, ClientIpAddress, BrowserInfo, current user/tenant, etc. Of course, you can override them.The security log store is implemented in Identity module.
Configure
AbpSecurityLogOptions
to provide the application name for the log or disable this feature. enabed by default.