diff --git a/README.md b/README.md index edf3bc4..b0b5d88 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,19 @@ $app->add(function (Request $request, Response $res, $next) { } }); ``` + + +## White listing +You may add a URI path for white listing. The whitelisting is based upon `strpos()` so you may use a URI fragment to whitelist a whole class of URIs. +With this it is possible to whitelist URIs by accident. + +Example: +```php + +$acl = new Acl(); +$acl->addWhitelistItem('/api'); +``` + +In this example any URI with `/api` will be whitelisted. +- `/api/*` +- `/myexample/api/*` diff --git a/tests/AclRepositoryTest.php b/tests/AclRepositoryTest.php index 09ae25a..dbee13b 100644 --- a/tests/AclRepositoryTest.php +++ b/tests/AclRepositoryTest.php @@ -180,5 +180,15 @@ public function testAclRepoUser2_yes() { $this->assertEquals(200, $output->getStatusCode()); } + public function testAclRepoGuest_Whitelist() { + $reqRoot = $this->mockRequest('/yes'); + $res = $this->mockResponse(401); + + $acl = $this->user2; + $acl->addWhiteListUri('/yes'); + $output = $acl($reqRoot, $res, $this->getClosure()); + + $this->assertEquals(200, $output->getStatusCode()); + } }