Open Closed

File Management Permissions #6850


User avatar
0
dhill created
  • ABP Framework version: v8.0.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server) - Azure Blob Storage
  • Steps to reproduce the issue:

We need to permission role based access to files and folders in the File Management module. Can you please provide any recommendations on how to accomplish?

Thanks


11 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    Can you please check this https://docs.abp.io/en/abp/latest/UI/Angular/Permission-Management

    Thanks

  • User Avatar
    0
    dhill created

    How are permissions mapped to File Management files and actions?

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    I have created one role as Admin and give him permissions of folder and again I have created one role Manager and give him permissions of file.

    permissions of Admin role

    permissions of manager role

    Now I have created 2 users, user1 and user2.

    user1 is assigned with role Admin and user2 is assigned with role manager. Check the permissions given to user1

    permissions given to user2

    Now user1 can have access to crud operations of Folders only and not of files.

    and user2 can have access to crud operations of Files only and not of folders.

    In this way you can implement as per your requirement.

    Thanks, Anjali

  • User Avatar
    0
    dhill created

    Hi Anjali

    I see what you're saying but we need to apply permissions on a per folder and per file basis.

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    If you have to apply permissions on a per folder and per file then you have to customize code at your own side .

    Thank you.

  • User Avatar
    0
    dhill created

    Can you give some guidance on a good place to start interacting with the existing code?

    Can we override any existing classes?

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    Please check the FileManagementPermissionsclass where all permissions are defined for this module. You can customize these permission as per your requirements.

    Thank you.

  • User Avatar
    0
    dhill created

    Hi

    It makes sense how to add permissions but what we need help with is where do we apply the permissions on a file by file basis?

    How do we mark a file as confidential for example and then based on a permission filter it out from being viewable in the directory tree?

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    ABP.io's file management module offers functionalities but doesn't provide built-in features for granular permissions on individual files. ABP's existing permission management system is used to grant access to folders based on user roles. The functionality you want to develop will require custom development efforts. You may also refer this https://docs.abp.io/en/commercial/latest/tutorials/book-store/part-5?UI=BlazorServer&DB=EF#permissions

    in summary it was enough to make a little bit research and we're supporting for lack of system not for specific custom logic 🙂

    I hope I could answer your question.

    Thanks,

  • User Avatar
    0
    dhill created

    We really need to understand better how to interact with the file management APIs so as to override them.

    Managing permissions isn't the requirement here. We need support in applying permissions against the module.

    Can we get some basic documentation and or explanation of how the module works?

    The wiki is very limited on this module.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It makes sense how to add permissions but what we need help with is where do we apply the permissions on a file by file basis?

    You can override the DirectoryDescriptorAppService and FileDescriptorAppService services.

    For example:

    [ExposeServices(typeof(IDirectoryDescriptorRepository))]
    [Dependency(ReplaceServices = true)]
    public class MyDirectoryDescriptorAppService : DirectoryDescriptorAppService
    {
        public MyDirectoryDescriptorAppService(IDirectoryManager directoryManager, IFileManager fileManager, IDirectoryDescriptorRepository directoryDescriptorRepository, IFileDescriptorRepository fileDescriptorRepository, IOptions<FileIconOption> fileIconOption) : base(directoryManager, fileManager, directoryDescriptorRepository, fileDescriptorRepository, fileIconOption)
        {
        }
    
        public override async Task<ListResultDto<DirectoryDescriptorInfoDto>> GetListAsync(Guid? parentId)
        {
            var list = await base.GetListAsync(parentId);
            foreach (var item in list.Items)
            {
                // check permission here
            }
        }
    }
    

    How do we mark a file as confidential for example and then based on a permission filter it out from being viewable in the directory tree?

    You can add an entity action to the action menu for an entity to make file as confidential

    https://docs.abp.io/en/abp/latest/UI/Blazor/Entity-Action-Extensions

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