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

Cannot use file upload access control for particular folder #3

Open
ErnestZiemkowski opened this issue Jan 3, 2019 · 0 comments
Open

Comments

@ErnestZiemkowski
Copy link

ErnestZiemkowski commented Jan 3, 2019

Hello!

I'm trying to deny file upload for one particular folder using this docs:
https://ckeditor.com/docs/ckfinder/ckfinder3-php/configuration.html#configuration_options_accessControl
However, it does not work.

Here's fragment of my access control code of my ckfinder_config.php:
`
/================================ Access Control =====================================/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_roleSessionVar

$config['roleSessionVar'] = 'CKFinder_UserRole';

// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_accessControl
$config['accessControl'][] = [
'role' => '',
'resourceType' => '
',
'folder' => '/',

'FOLDER_VIEW'         => true,
'FOLDER_CREATE'       => true,
'FOLDER_RENAME'       => true,
'FOLDER_DELETE'       => true,

'FILE_VIEW'           => true,
'FILE_UPLOAD'         => true,
'FILE_RENAME'         => true,
'FILE_DELETE'         => true,

'IMAGE_RESIZE'        => true,
'IMAGE_RESIZE_CUSTOM' => true

];

$config['accessControl'][] = [
'role' => '',
'resourceType' => '
',
'folder' => '/ankieteo',

'FOLDER_CREATE'       => false,
'FOLDER_DELETE'       => false,
'FOLDER_RENAME'       => false,

'FILE_UPLOAD'         => false,
'FILE_RENAME'         => false,
'FILE_DELETE'         => false,

'IMAGE_RESIZE'        => false,
'IMAGE_RESIZE_CUSTOM' => false

];
and here's my overrideConfig method: protected function overrideConfig()
{
$this->connectorConfig['images'] = [
'maxWidth' => 1200,
'maxHeight' => 1200,
'quality' => 80,
'sizes' => [
'small' => ['width' => 480, 'height' => 320, 'quality' => 80],
'medium' => ['width' => 600, 'height' => 480, 'quality' => 80],
'large' => ['width' => 800, 'height' => 600, 'quality' => 80]
]
];

    $this->connectorConfig['resourceTypes'] = [];
    $this->connectorConfig['resourceTypes'][] = [
        'name'              => 'images',
        'label'             => 'Zdjęcia',
        'directory'         => $this->tokenStorage->getToken()->getUser()->getId().'/images',
        'maxSize'           => 0,
        'allowedExtensions' => 'bmp,gif,jpeg,jpg,png',
        'deniedExtensions'  => '',
        'backend'           => 'default'
    ];

    $this->connectorConfig['resourceTypes'][] = [
        'name'              => 'videos',
        'label'             => 'Filmy',
        'directory'         => $this->tokenStorage->getToken()->getUser()->getId().'/videos',
        'maxSize'           => 0,
        'allowedExtensions' => 'mp4',
        'deniedExtensions'  => '',
        'backend'           => 'default'
    ];

    $this->connectorConfig['resourceTypes'][] = [
        'name'              => 'audios',
        'label'             => 'Audio',
        'directory'         => $this->tokenStorage->getToken()->getUser()->getId().'/audios',
        'maxSize'           => 0,
        'allowedExtensions' => 'mp3',
        'deniedExtensions'  => '',
        'backend'           => 'default'
    ];

    $this->connectorConfig['resourceTypes'][] = [
        'name'              => 'ankieteo',
        'label'             => 'Ankieteo',
        'directory'         => '/ankieteo',
        'maxSize'           => 0,
        'allowedExtensions' => 'bmp,gif,jpeg,jpg,png',
        'deniedExtensions'  => '',
        'backend'           => 'default'
    ];

    if ($this->tokenStorage->getToken()->getUser()->getGroup()) {
        $this->connectorConfig['resourceTypes'][] = [
            'name'              => 'group/videos',
            'label'             => mb_substr($this->tokenStorage->getToken()->getUser()->getGroup()->getName(), 0, 11).' - Filmy',
            'directory'         => 'groups/'.$this->tokenStorage->getToken()->getUser()->getGroup()->getId().'/videos',
            'maxSize'           => 0,
            'allowedExtensions' => 'mp4',
            'deniedExtensions'  => '',
            'backend'           => 'default'
        ];

        $this->connectorConfig['resourceTypes'][] = [
            'name'              => 'group/images',
            'label'             => mb_substr($this->tokenStorage->getToken()->getUser()->getGroup()->getName(), 0, 11).' - Zdjęcia',
            'directory'         => 'groups/'.$this->tokenStorage->getToken()->getUser()->getGroup()->getId().'/images',
            'maxSize'           => 0,
            'allowedExtensions' => 'bmp,gif,jpeg,png',
            'deniedExtensions'  => '',
            'backend'           => 'default'
        ];

        $this->connectorConfig['resourceTypes'][] = [
            'name'              => 'group/audios',
            'label'             => mb_substr($this->tokenStorage->getToken()->getUser()->getGroup()->getName(), 0, 11).' - Audio',
            'directory'         => 'groups/'.$this->tokenStorage->getToken()->getUser()->getGroup()->getId().'/audios',
            'maxSize'           => 0,
            'allowedExtensions' => 'mp3',
            'deniedExtensions'  => '',
            'backend'           => 'default'
        ];
    }
}

`

And here's how it looks in the end. The upload file button still exists:
ckfinder_access_controll_file_upload_bug

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

No branches or pull requests

1 participant