10
Access Control PHP >= 5.3
This example shows how you can extend the authentication system to create a robust access control system. As a added bonus we also restrict api documentation based on the same.
When the api_key
is
- blank you will see the public api
12345
you will see the api that is accessible by an user67890
you will see all api as you have the admin rights
Try it out yourself here
This API Server is made using the following php files/folders
- index.php (gateway)
- Access.php (api)
- Resources.php (api)
- AccessControl.php (auth)
- restler.php (framework)
- JsonFormat.php (format)
This API Server exposes the following URIs
GET admin ⇠ Access::admin()
GET all ⇠ Access::all()
GET resources ⇠ Luracast\Restler\Resources::index()
GET resources/verifyaccess ⇠ Luracast\Restler\Resources::verifyAccess()
GET resources/{id} ⇠ Luracast\Restler\Resources::get()
GET user ⇠ Access::user()