Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lamngockhuong/0a3ef3615da69350c91816e2cdbc6ac3 to your computer and use it in GitHub Desktop.
Save lamngockhuong/0a3ef3615da69350c91816e2cdbc6ac3 to your computer and use it in GitHub Desktop.
[CKFinder Authentication Configuration for laravel 5] #laravel #ckfinder #ckeditor

Open and edit file 'ckfinder/config.php':

require dirname(__DIR__, 3) .'/vendor/autoload.php';
$app = require dirname(__DIR__, 3) . '/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$kernel->handle($request = Illuminate\Http\Request::capture());

$config['authentication'] = function () {
    if (auth()->guest()) {
        return false;
    } else {
        return auth()->user()->is_admin; // is_admin: attribute in model
    }
};


@alantulais
Copy link

Laravel 5.7+:

require  $_SERVER['DOCUMENT_ROOT'] . '/../vendor/autoload.php';
$app = require_once  $_SERVER['DOCUMENT_ROOT']. '/../bootstrap/app.php';
$response = $app->make('Illuminate\Contracts\Http\Kernel')->handle(Illuminate\Http\Request::capture());
$cookie = $_COOKIE[$app['config']['session']['cookie']] ?? false;
if ($cookie) {
    $id = $app['encrypter']->decrypt($cookie, false);
    $session = $app['session']->driver();
    $session->setId($id);
    $session->start();
}

if (!$app['auth']->check()){
    header('HTTP/1.0 403 Forbidden'); exit();
}

@TylerLumen
Copy link

@alantulais:

When try it. I get this error:
Call to a member function make() on bool

@cyimking
Copy link

cyimking commented Feb 6, 2019

@alan

@alantulais:

When try it. I get this error:
Call to a member function make() on bool

Were you able to find a solution? I am getting the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment