Skip to content

Commit

Permalink
added authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
blacknell committed Jan 13, 2019
1 parent 4b3d0f0 commit 53d6339
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ For example, to allow a client on a website http://myclient.com to access your A
}
```
#### Authentication
Overide `RestAPI::isAuthenticated()` to handle authentication and only return `true` if the request is authorised.
As a basic example, force the request to include a header such as `Authentication-Token: xxx` and test this in your derived class.
```
protected function isAuthenticated()
{
$headers=getallheaders();
if($headers['Authentication-Token'] !== 'xxx') {
return false;
} else {
return parent::isAuthenticated();
}
}
```

## Error Handling
Any endpoint not mapping to a protected function in your derived class results in the following JSON response.
```
Expand Down

0 comments on commit 53d6339

Please sign in to comment.