Skip to content
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

Entity history is not always recorded #11682

Open
irvingHerrera opened this issue Feb 23, 2022 · 31 comments
Open

Entity history is not always recorded #11682

irvingHerrera opened this issue Feb 23, 2022 · 31 comments
Assignees
Labels
Milestone

Comments

@irvingHerrera
Copy link

  • ABP Framework version 5.1.3.
  • User Interface Blazor Server
  • database provider EF Core

Hi!
I am using the history of entities, the project currently started in version 4.3, migrated to 4.4 and finally to version 5.1.3

When the project updated to version 5.1.3 the entity history started to fail.
After doing some tests I have been able to notice the following.

The next HubFilter on this line there is nothing UI action (auditingManager.Current.Log.Actions).

Continuing with the tests that I have carried out, I have noticed that it is possibly a concurrency problem when generating the scope of auditingManager and registering the action in the AuditingInterceptor.cs class.

Unfortunately I couldn't solve the problem.
Any idea how I could fix this?.

Thank you very much

@maliming maliming self-assigned this Feb 24, 2022
@maliming
Copy link
Member

hi

You can replace it with your AuditHubFilter. I will check the Actions issue.

@irvingHerrera
Copy link
Author

I have replaced AuditHubFilter with a custom one but I still can't find the problem. I managed to see that every UI related action generates a scope for audilog.

I have verified that it is possible to filter with auditingManager.Current.Log.Actions.IsNullOrEmpty(). But I have noticed that the actions are generated when some method of the Applications layer is called.
Then AuditingInterceptor comes into action but I have not been able to verify what the interceptor comes from on which generated scope.

A scope is generated for each event performed on the UI (click, hover, over, mousevent, etc.)

I have been able to notice that if it detects the changes made in the entity but there comes a point where the tracking of the action is lost
is there a way in AuditingIntercept to know which scope corresponds to the generated action?

Thank you very much

@maliming
Copy link
Member

hi

I made a new changes: #11687

@maliming maliming removed this from the 5.2-preview milestone Mar 2, 2022
@maliming maliming removed their assignment Mar 2, 2022
@irvingHerrera
Copy link
Author

irvingHerrera commented Mar 3, 2022

Hi maliming.

I hope you are well.
I have updated abp to version 5.1.4 where I can see your changes being applied.
But the above mentioned problem here persists

I was able to detect that in the AuditingInterceptor class on the line he execution of the method is done in the application layer, which is just when I perform an action on the database

In the AbpDbContext class on this line auditLog is null and does not get the changes made to the entity.

Apparently the scope that arrives in SaveChangesAsync is not the same as the one that is being executed in AuditingInterceptor but auditLog is initialized in the AuditingInterceptor class.

I've been trying to figure this out but couldn't find a solution, do you have any idea how I could solve this?
Thank you very much

I have prepared an example repository where you can see the behavior mentioned here repo

@maliming
Copy link
Member

maliming commented Mar 4, 2022

hi

I will check it.

@maliming
Copy link
Member

maliming commented Mar 4, 2022

See #11807

context.Services.AddSignalR(options =>
{
    var p = options.GetType().GetProperty("HubFilters", BindingFlags.Default | BindingFlags.Instance | BindingFlags.NonPublic);
    var pp = p.GetValue(options);
    var m = typeof(List<IHubFilter>).GetMethod("Clear");
    m.Invoke(pp, BindingFlags.Default, null, null, null);

    options.AddFilter<AbpHubContextAccessorHubFilter>();
    options.AddFilter<AbpAuthenticationHubFilter>();
    options.AddFilter<AbpUowHubFilter>();
    options.AddFilter<AbpAuditHubFilter>();
});

@irvingHerrera
Copy link
Author

Hi maliming.

i have checked the latest version of abp 5.2 RC1 I can notice that the changes mentioned here are already implemented.
But now I see that they have removed the AbpAuditHubFilter filter.

I've made the changes you mention to the signalr middleware and it overrides the AbpUowHubFilter filter so it doesn't do anything so entity history is back to work

Will anything change for the final 5.2 release as an internal fix for abp?

Thank you

@maliming
Copy link
Member

maliming commented Mar 13, 2022

Since Blazor's mechanism(dotnet/aspnetcore#30115) AbpUowHubFilter may be have bugs, I rolled back the commit and am working on the latest solution.

@maliming maliming self-assigned this Mar 25, 2022
@maliming maliming added this to the 5.3-preview milestone Mar 25, 2022
@maliming maliming modified the milestones: 5.3-preview, 5.4-preview Apr 28, 2022
@maliming maliming modified the milestones: 5.4-preview, 6.0-preview May 16, 2022
@hikalkan hikalkan modified the milestones: 6.0-preview, 7.0-preview May 24, 2022
@magicjar
Copy link
Contributor

Any news on this?

@maliming
Copy link
Member

No. #11682 (comment)

@maliming maliming modified the milestones: 7.0-preview, 7.1-preview Sep 27, 2022
@maliming maliming modified the milestones: 7.1-preview, backlog Nov 10, 2022
@puschie286
Copy link

puschie286 commented Nov 25, 2022

It looks like Microsoft won't be fixing the problem anytime soon
what do you recommend as a workaround - audit logging is a security feature, so the current state is a security risk
Currently, only deletions are logged

Is it possible to trigger the audit logging manually ( within dbcontext or the repository ) ?

@alpisala02
Copy link

Is there any solutions ? Its been more than a year since this ticket opened. We need help.

@maliming
Copy link
Member

maliming commented May 3, 2023

No. #11682 (comment)

@ogulcancakir
Copy link

It looks like Microsoft won't be fixing the problem anytime soon what do you recommend as a workaround - audit logging is a security feature, so the current state is a security risk Currently, only deletions are logged

Is it possible to trigger the audit logging manually ( within dbcontext or the repository ) ?

@puschie286
Have you found a solution in this way?

@puschie286
Copy link

@ogulcancakir sry but no - only not to rely on the entity history :/

@alireza-4taghavi
Copy link

Is this fixed now guys?

@maliming
Copy link
Member

Not yet.

Is this fixed now guys?

@alireza-4taghavi
Copy link

Is there any work around on this? I really need to have the entity changes to my system, we are going to publish our product soon

@alireza-4taghavi
Copy link

Only one or two entity to have their logs in enough for now

@maliming
Copy link
Member

#11682 (comment)

@alireza-4taghavi
Copy link

Can you guide me more please? how to solve it ?

@maliming
Copy link
Member

Due to the current limitations of blazor, it cannot be resolved.

@alireza-4taghavi
Copy link

So any alternative way to implement this feature?

@margareteryan
Copy link

I am also in need of an alternative. Audit log is necessary for our site.

@MannRobertJ
Copy link

See #11807

context.Services.AddSignalR(options =>
{
    var p = options.GetType().GetProperty("HubFilters", BindingFlags.Default | BindingFlags.Instance | BindingFlags.NonPublic);
    var pp = p.GetValue(options);
    var m = typeof(List<IHubFilter>).GetMethod("Clear");
    m.Invoke(pp, BindingFlags.Default, null, null, null);

    options.AddFilter<AbpHubContextAccessorHubFilter>();
    options.AddFilter<AbpAuthenticationHubFilter>();
    options.AddFilter<AbpUowHubFilter>();
    options.AddFilter<AbpAuditHubFilter>();
});

This solution without AbpUowHubFiler and AbpAuditHubFilter seems to work. Is this currently a recommended approach?

@maliming
Copy link
Member

hi @MannRobertJ

There are currently no other options.

@Jawad-Chughtai
Copy link

Hi, I am also facing the same issue. Did it get resolved in .Net 8 ?

@maliming
Copy link
Member

Hi, I am also facing the same issue. Did it get resolved in .Net 8 ?

Not yet.

@liuahifancy
Copy link

Abp 8.1.1 also not fixed,Follow-up continue to follow

@liuahifancy
Copy link

Abp 8.2 also not fixed,Follow-up continue to follow

@margareteryan
Copy link

Hello, did this get resolved in .Net 9? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests