*/ $app->register(new \Silex\Provider\SecurityServiceProvider()); $app->register(new \CultuurNet\SilexServiceProviderJwt\JwtServiceProvider()); $app['permissions_voter'] = $app->share(function ($app) { return new PermissionsVoter($app['config']['user_permissions']); }); $app['user_permissions_voter'] = $app->share(function ($app) { return new UserPermissionsVoter($app[UserPermissionsServiceProvider::USER_PERMISSIONS_READ_REPOSITORY]); }); $app['security.voters'] = $app->extend('security.voters', function ($voters) use($app) { return array_merge($voters, [$app['permissions_voter'], $app['user_permissions_voter']]); }); $app['security.access_manager'] = $app->share(function ($app) { return new AccessDecisionManager($app['security.voters'], AccessDecisionManager::STRATEGY_AFFIRMATIVE); }); $app['security.access_rules'] = array(array(MultiPathRequestMatcher::fromPaths([new Path('^/labels/.*', ['POST', 'DELETE', 'PATCH'])]), Permission::LABELS_BEHEREN), array('^/(roles|permissions|users)/.*', Permission::GEBRUIKERS_BEHEREN)); require __DIR__ . '/../debug.php'; $app['logger.search'] = $app->share(function ($app) { $logger = new \Monolog\Logger('search'); $handlers = $app['config']['log.search']; foreach ($handlers as $handler_config) { switch ($handler_config['type']) { case 'hipchat': $handler = new \Monolog\Handler\HipChatHandler($handler_config['token'], $handler_config['room']); break; case 'file': $handler = new \Monolog\Handler\StreamHandler(__DIR__ . '/' . $handler_config['path']); break; default: continue 2; }
/** * @test */ public function it_should_match_against_paths_created_with_from_paths_method() { $matcher = MultiPathRequestMatcher::fromPaths([new Path('^/some/path', ['GET', 'POST']), new Path('^/some/other/path', 'DELETE')]); $matchingRequest = Request::create('/some/path', 'GET'); $matches = $matcher->matches($matchingRequest); $this->assertTrue($matches); $nonMatchingRequest = Request::create('/some/other/path', 'GET'); $matches = $matcher->matches($nonMatchingRequest); $this->assertFalse($matches); }