Skip to content

Commit

Permalink
Change index.php file to support filesystem and new authentication UR…
Browse files Browse the repository at this point in the history
…L scheme.
  • Loading branch information
Potherca committed Aug 23, 2020
1 parent e977a97 commit 7723ae5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use League\Route\Http\Exception\HttpExceptionInterface;
use League\Route\Http\Exception\NotFoundException;
use League\Route\Router;
use function MJRider\FlysystemFactory\create as createFileSystem;

/*/ Generic Pdsinterop /*/
use Pdsinterop\Authentication\Enum\ServerPrefix;
use Pdsinterop\Authentication\Router as ProjectRouter;

/*/ Resource Server /*/
use Pdsinterop\Authentication\Resource\Handler\Authentication;
use Pdsinterop\Authentication\Resource\Router as ResourceRouter;

require_once __DIR__ . '/../vendor/autoload.php';
Expand All @@ -25,6 +27,8 @@
// Configuration
// -----------------------------------------------------------------------------
$clientIdentifier = 'PDS Interop OAuth Example App';

$location = getenv('STORAGE_ENDPOINT') ?: 'local:'.dirname(__DIR__) . '/tests/fixtures/files';
// =============================================================================


Expand All @@ -38,6 +42,12 @@
'Host' => $request->getUri()->getHost(),
'Port' => $request->getUri()->getPort() ? ':'.$request->getUri()->getPort() : '',
]);

$filesystem = createFileSystem($location);

$publicResources = [
'public_resource.txt'
];
/*/ ======================================================================== /*/


Expand All @@ -49,7 +59,12 @@

$routes = [
'/' => new ProjectRouter($response),
ServerPrefix::RESOURCE => new ResourceRouter($response),
ServerPrefix::RESOURCE => new ResourceRouter(
$response,
$filesystem,
new Authentication($response),
$publicResources
),
];

array_walk($routes, static function ($handler, $route) use (&$router) {
Expand Down

0 comments on commit 7723ae5

Please sign in to comment.