我正在尝试将 CKFinder 与 Laravel 集成,我已经完成了 95% 左右。我可以让一切正常工作,除了CheckAuthentication
功能 - 我必须做到return true
无论上传是否有效。
我尝试做的是在 config.php 文件中引导 Laravel,然后检查用户是否登录,如下所示:
公共/包/ckfinder/config.php
<?php
/*
* ### CKFinder : Configuration File - Basic Instructions
*
* In a generic usage case, the following tasks must be done to configure
* CKFinder:
* 1. Check the $baseUrl and $baseDir variables;
* 2. If available, paste your license key in the "LicenseKey" setting;
* 3. Create the CheckAuthentication() function that enables CKFinder for authenticated users;
*
* Other settings may be left with their default values, or used to control
* advanced features of CKFinder.
*/
/** RIPPED FROM public/index.php **/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../../../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let's turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight these users.
|
*/
$app = require __DIR__.'/../../../bootstrap/start.php';
/** END public/index.php **/
/**
* This function must check the user session to be sure that he/she is
* authorized to upload and access files in the File Browser.
*
* @return boolean
*/
function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
return Auth::check();
}
不过,这总是返回 false。我也尝试过直接使用 Laravel 的Session
当有人登录时将变量设置为 true,当他们注销时将变量设置为 false,然后在 config.php 文件中检查该变量,但它总是返回默认值Session::get("IsAuthorized", false);
。任何人都可以提供一些指导 -
1)如何验证用户是否允许上传?
2)为什么在另一个文件中引导 Laravel 似乎会导致它使用单独的会话,即使它正在加载相同的文件?
我尝试将 simogeo 的 Filemanager 和 KCFinder 集成到 Laravel 项目中,发现了同样的问题。
使用此代码,可以共享 Laravel 的会话并检查来自外部项目的身份验证:
https://gist.github.com/frzsombor/ddd0e11f93885060ef35 https://gist.github.com/frzsombor/ddd0e11f93885060ef35
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)