Comments (9)
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.
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.
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.
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.
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.
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.
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.
from laravel-file-manager.
In case of blacklist, It is working.
from laravel-file-manager.
Thank you. It is working.
from laravel-file-manager.
Related Issues (20)
- #Laravel 10 - Your requirements could not be resolved to an installable set of packages.
- No listing directories on table selected
- Modal UI error after updating bootstrap 5.3.2 HOT 2
- Not able to find the folder details api call
- For text edit - is using CodeMirror library. Could I use visual studio code (vs code) in codeMirror Library?
- Rename folder not working for S3 HOT 1
- Package intervention/imagecache is abandoned,
- How to integrate with Laraberg?
- (FTP disk) 500 Error when creating a new folder - Directory not found
- Great work! But .... PDF open by dbl click doesn't work! HOT 1
- File extensions not showing in table view
- Modal not showing
- Not Inatalled laravel 10 HOT 1
- Upgrade to support Laravel 11 HOT 5
- downgrade to support laravel 8 framework HOT 1
- Not found error at first page
- How to paginate?
- Set root = public_path HOT 1
- BunnyCDN Storage Integration - Unable to fetch sub folders
- Not working zip, delete, upload, rename,
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-file-manager.