芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/mctv/web/api/authorize/index.php
. */ use Monolog\Logger; use Monolog\Processor\UidProcessor; use Slim\Http\Response as Response; use Slim\Http\ServerRequest as Request; use Xibo\Factory\ContainerFactory; DEFINE('XIBO', true); define('PROJECT_ROOT', realpath(__DIR__ . '/../../..')); error_reporting(1); ini_set('display_errors', 1); require PROJECT_ROOT . '/vendor/autoload.php'; if (!file_exists(PROJECT_ROOT . '/web/settings.php')) die('Not configured'); // Create the container for dependency injection. try { $container = ContainerFactory::create(); } catch (Exception $e) { die($e->getMessage()); } $container->set('logger', function () { $logger = new Logger('AUTH'); $uidProcessor = new UidProcessor(); // db $dbhandler = new \Xibo\Helper\DatabaseLogHandler(); $logger->pushProcessor($uidProcessor); $logger->pushHandler($dbhandler); return $logger; }); // Create a Slim application $app = \DI\Bridge\Slim\Bridge::create($container); $app->setBasePath($container->get('basePath')); // Config $app->config = $container->get('configService'); $routeParser = $app->getRouteCollector()->getRouteParser(); $container->set('name', 'auth'); // Config $app->add(new \Xibo\Middleware\ApiAuthentication($app)); $app->add(new \Xibo\Middleware\State($app)); $app->add(new \Xibo\Middleware\Log($app)); $app->add(new \Xibo\Middleware\Storage($app)); $app->addRoutingMiddleware(); $app->add(new \Xibo\Middleware\TrailingSlashMiddleware($app)); // Define Custom Error Handler $errorMiddleware = $app->addErrorMiddleware(true, true, true); $errorMiddleware->setDefaultErrorHandler(\Xibo\Middleware\Handlers::jsonErrorHandler($container)); // Auth Routes $app->get('/', function(Request $request, Response $response) use ($app) { /** @var \League\OAuth2\Server\AuthorizationServer $server */ $server = $app->getContainer()->get('server'); $authRequest = $server->validateAuthorizationRequest($request); // Redirect the user to the UI - save the auth params in the session. $app->getContainer()->get('session')->set('authParams', $authRequest); return $response->withRedirect(str_replace('/api/authorize/', '/application/authorize', $request->getUri()->getPath())); })->setName('home'); // Access Token $app->post('/access_token', function(Request $request, Response $response) use ($app) { $app->getContainer()->get('logService')->debug('Request for access token using grant_type: %s', $request->getParam('grant_type')); $server = $app->getContainer()->get('server'); // Try to respond to the request return $server->respondToAccessTokenRequest($request, $response); }); // Run app $app->run();