Starts in:
0 DAY
20 HRS
15 MIN
53 SEC
Starts in:
0 D
20 H
15 M
53 S
Open Closed

Permissions update and delete #7941


User avatar
0
cetin.sahin created
  • ABP Framework version: v8.1.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server,
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue: Hi; Permissions can change in projects. They are not only added but also removed and modified. When running the DB migration project, it does not update or delete permissions on the code side; it only adds the new ones to the [dbo].[AbpPermissions] table.

we request that the DB migrator project updates the relevant tables with the latest permissions from the code side when it runs.

What would your recommendation be on this issue?


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The StaticPermissionSaver will remove old permissions. https://github.com/abpframework/abp/blob/rel-8.2/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/StaticPermissionSaver.cs#L186

    you can use PermissionOptions to configure them.

    Configure<AbpPermissionOptions>(options =>
    {
        options.DeletedPermissions = ...;
        options.DeletedPermissionGroups = ...;
    });
    
  • User Avatar
    0
    cetin.sahin created

    We wil try it and return

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    okay

  • User Avatar
    0
    cetin.sahin created

    "When we run the DbMigrator project, we want the permissions to be deleted. I don't understand the part with

    Configure<AbpPermissionOptions>(options => { options.DeletedPermissions = ...; options.DeletedPermissionGroups = ...; });. 
    

    There is no configuration here, and DeletedPermissions and DeletedPermissionGroups are just lists. I tried to override the StaticPermissionSaver and customize it myself. I tried to override it in all layers, including DbMigrator, and when I run DbMigrator, it doesn't hit the breakpoint. So i failed. I need the permissions that have been removed or modified to also be deleted or updated in the database when I run the DbMigrator project. I need your support on this matter.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Because it disabled for dataMigratior by default.

    You can try enable it.

  • User Avatar
    0
    cetin.sahin created

    liangshiwei after this config i can override StaticPermissionSaver and also found the problem.

    When running DbMigrator UpdateChangedPermissionsAsync method can not find deleted permission. because PermissionOptions.DeletedPermissions is always null. Also because of matching permissions with name, when permission name changes (in our scenario it changes) UpdateChangedPermissionsAsync thinks that it is new permission. so insert a new permission to database but in database old permission still exists.

    The reason we want this is because our application becomes very slow when there are garbage permissions in our database. The system probably enters a loop because there is a difference between the permissions in Redis and the database.

    Anyway i changed the StaticPermissionSaver. Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06