Giter Site home page Giter Site logo

Comments (9)

alexusmai avatar alexusmai commented on June 30, 2024 1

Yes, you can create your own class, for example in the folder /app/HTTP

<?php

namespace App\Http;

use Alexusmai\LaravelFileManager\ACLService\ACLRepository;

class MyACLRepository implements ACLRepository
{
    /**
     * Get user ID
     *
     * @return mixed
     */
    public function getUserID()
    {
        return \Auth::id();
    }

    /**
     * Get ACL rules list for user
     *
     * @return array
     */
    public function getRules(): array
    {
        return \DB::table('acl_rules')
            ->where('user_id', $this->getUserID())
            ->get(['disk', 'path', 'access'])
            ->map(function ($item) {
                return get_object_vars($item);
            })
            ->all();
    }
}

in /config/file-manager change:

    'aclRepository' => \App\Http\MyACLRepository::class,

Warning the getRules() method must return an array, not a object !!! see my example!

from laravel-file-manager.

alexusmai avatar alexusmai commented on June 30, 2024 1

whitelist - Deny everything, that not allowed by the ACL rules list.

Main folder too!!!

Add new rule:

['disk' => 'local', 'path' => '/', 'access' => 2],

OR

['disk' => 'local', 'path' => '/', 'access' => 1],

from laravel-file-manager.

alexusmai avatar alexusmai commented on June 30, 2024

You probably did not configure everything as necessary. ACL is needed only to restrict user access to files and folders. And the main directory that will be displayed is set in the disk settings. See Laravel docs - https://laravel.com/docs/5.6/filesystem , in /config/filesystems.php set your disks, and then add disks what you want to FM config (/config/file-manager.php)

// Example
/**
     * list of disk names that you want to use
     * (from config/filesystems)
     */
    'diskList'  => ['images', 'docs', 'template', 'sftp', 'yandex'],

from laravel-file-manager.

Ahmadzia307 avatar Ahmadzia307 commented on June 30, 2024

Thank you for replying. One more thing, how I can use aclRule array in the laravel. Can you add some example in the documentation that would be very helpful?
So far, I am able to use the file manager with disklist =>['local']. Just I wasn't able to apply the aclRule array on the directory.

from laravel-file-manager.

alexusmai avatar alexusmai commented on June 30, 2024

Example:

I have disk 'images' in /config/filesystems.php for folder /public/images

'disks' => [

        'images' => [
            'driver' => 'local',
            'root'   => public_path('images'),
            'url'    => '/images/',
        ],
]

This disk contain:

/                  // disk root folder
|-- nature    // folder
|-- cars        // folder
|-- icons
|-- image1.jpg   // file
|-- image2.jpg
|-- avatar.png

I add this disk to file-manager config file

'diskList'  => ['images'],

'aclStrategy'   => 'blacklist',

// now it's a black list
'aclRules'      => [
       // null - for not authenticated users
        null => [
            ['disk' => 'images', 'path' => 'nature', 'access' => 0],    // guest don't have access for this folder
            ['disk' => 'images', 'path' => 'icons', 'access' => 1],    // only read - guest can't change folder - rename, delete
            ['disk' => 'images', 'path' => 'icons/*', 'access' => 1],     // only read all files and foders in this folder
            ['disk' => 'images', 'path' => 'image*.jpg', 'access' => 0], // can't read and write (preview, rename, delete..)
            ['disk' => 'images', 'path' => 'avatar.png', 'access' => 1],     // only read (view)

        ],
        // for user with ID = 1
        1 => [
            ['disk' => 'images', 'path' => 'cars', 'access' => 0],    // don't have access
            ['disk' => 'public', 'path' => 'image*.jpg', 'access' => 1],    // only read (view)
        ],
    ],

from laravel-file-manager.

Ahmadzia307 avatar Ahmadzia307 commented on June 30, 2024

Thanks alot. I just tried it and it worked.
In case of DB , Can I make my own class of the Dbrespository with two functions getID() and getRules?
Can you give me some idea how I can do it?
Right now, it is in vendor and with User table. Also,I want to change the table with my own table.

from laravel-file-manager.

Ahmadzia307 avatar Ahmadzia307 commented on June 30, 2024

Hi alex,
I am having a problem using acl rules with "whitelist". My Aclrule is below:
I have folders in local which is in
"public/files/"
-1
-2
-img

'aclStrategy' => 'whitelist',
aclRules' => [
null => [
['disk' => 'local', 'path' => 'img', 'access' => 2],
['disk' => 'local', 'path' => '1', 'access' => 0],
],
]`

Then when I run this, I got the error, Acess Denied.
screenshot from 2019-02-11 07-48-50

from laravel-file-manager.

Ahmadzia307 avatar Ahmadzia307 commented on June 30, 2024

In case of blacklist, It is working.
screenshot from 2019-02-11 07-52-24

from laravel-file-manager.

Ahmadzia307 avatar Ahmadzia307 commented on June 30, 2024

Thank you. It is working.

from laravel-file-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.