You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
<?php
|
|
|
|
use \Slim\Middleware\HttpBasicAuthentication\PdoAuthenticator;
|
|
use Chadicus\Slim\OAuth2\Http\RequestBridge;
|
|
use Chadicus\Slim\OAuth2\Http\ResponseBridge;
|
|
use Chadicus\Slim\OAuth2\Middleware;
|
|
use Tuupola\Middleware\CorsMiddleware;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
use Symfony\Component\Yaml\Exception\ParseException;
|
|
use MongoDB\Client;
|
|
|
|
$container = $app->getContainer();
|
|
$Lclient = $container['httpClient'];
|
|
$y2j = $container['y2j'];
|
|
$MongoClient = $container['mongo'];
|
|
$pdo = $container['db'];
|
|
|
|
|
|
|
|
$storage = new OAuth2\Storage\Pdo($pdo);
|
|
// create the oauth2 server
|
|
$server = new OAuth2\Server(
|
|
$storage,
|
|
[
|
|
'access_lifetime' => 3600,
|
|
],
|
|
[
|
|
new OAuth2\GrantType\ClientCredentials($storage),
|
|
new OAuth2\GrantType\AuthorizationCode($storage),
|
|
]
|
|
);
|
|
|
|
|
|
// create the authorization middlware
|
|
$authMiddleware = new Middleware\Authorization($server, $app->getContainer());
|
|
|
|
// Routes
|
|
//get
|
|
require_once ("routes/get/helloworld.php");
|
|
//post
|
|
require_once ("routes/post/token.php");
|
|
require_once ("routes/post/helloworld.php");
|
|
// Catch-all route to serve a 404 Not Found page if none of the routes match
|
|
// NOTE: make sure this route is defined last
|
|
|
|
|