Skip to content

Instantly share code, notes, and snippets.

@ganey
Forked from frzsombor/gist:ddd0e11f93885060ef35
Last active August 29, 2015 14:13
Show Gist options
  • Save ganey/fe539b2431eefaf5401b to your computer and use it in GitHub Desktop.
Save ganey/fe539b2431eefaf5401b to your computer and use it in GitHub Desktop.
<?php
/*
This is a fork of https://gist.github.com/frzsombor/ddd0e11f93885060ef35
Thanks frzsombor!
|--------------------------------------------------------------------------
| Checking the Sentry Auth for CKFinder CheckAuthentication
|--------------------------------------------------------------------------
| Put in the CKFinder config.php within the CheckAuthentication() function.
|
| The following code is tested with Laravel 4.2.11
|
| Last update: 2015-01-09
|
*/
$isAuthorized = false;
try {
require $_SERVER['DOCUMENT_ROOT'] . '/../bootstrap/autoload.php';
$app = require_once $_SERVER['DOCUMENT_ROOT'] . '/../bootstrap/start.php';
$request = $app['request'];
$client = (new \Stack\Builder)
->push('Illuminate\Cookie\Guard', $app['encrypter'])
->push('Illuminate\Cookie\Queue', $app['cookie'])
->push('Illuminate\Session\Middleware', $app['session'], null);
$stack = $client->resolve($app);
$stack->handle($request);
if (class_exists('Sentry')) {
$isAuthorized = Sentry::check();
}
} catch (Exception $e) {
$isAuthorized = false;
}
return $isAuthorized?true:false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment