Skip to content

Commit

Permalink
REST API module supports authorising restricted reports
Browse files Browse the repository at this point in the history
For a specific client project, resource options can contain a list of
authorised reports that are normally restricted.
  • Loading branch information
johnvanbreda committed Feb 5, 2019
1 parent 6f5fddf commit d494144
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/rest_api/config/rest.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@
// Optional, which resources are available? Default is all.
'resources' => ['taxon-observations', 'annotations', 'reports'],
'resource_options' => [
'reports' => ['raw_data', 'featured'],
'reports' => [
'raw_data',
'featured',
'authorise' => [
// Authorise a normally restricted report for this project.
'library/occurrences/list_for_elastic_all.xml',
],
],
],
// Set the following to TRUE for Indicia to automatically feed through
// pages of data. Useful when the client is a dumb poller for the data.
Expand Down
5 changes: 5 additions & 0 deletions modules/rest_api/controllers/services/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,11 @@ private function loadReportEngine() {
// array.
if (!isset($this->reportEngine)) {
$this->reportEngine = new ReportEngine(array($this->clientWebsiteId));
// Resource configuration can provide a list of restricted reports that
// are allowed for this client.
if (isset($this->resourceOptions['authorise'])) {
$this->reportEngine->setAuthorisedReports($this->resourceOptions['authorise']);
}
}
}

Expand Down

0 comments on commit d494144

Please sign in to comment.