Skip to content

Commit

Permalink
Add permission checks where missing, refs #7356
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Jan 28, 2015
1 parent 6247f18 commit d0a3711
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 3 deletions.
6 changes: 6 additions & 0 deletions apps/qubit/modules/actor/actions/deleteAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public function execute($request)
$this->forward404();
}

// Check user authorization
if (!QubitAcl::check($this->resource, 'delete'))
{
QubitAcl::forwardUnauthorized();
}

if ($request->isMethod('delete'))
{
foreach ($this->resource->events as $item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class ContactInformationIndexAction extends sfAction
{
public function execute($request)
{
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}

$this->resource = QubitContactInformation::getById($request->id);

if (!isset($this->resource))
Expand Down
6 changes: 6 additions & 0 deletions apps/qubit/modules/default/actions/editAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ protected function processForm()

public function execute($request)
{
// Force subclassing
if ('default' == $this->context->getModuleName() && 'edit' == $this->context->getActionName())
{
$this->forward404();
}

$this->form = new sfForm;

$this->earlyExecute();
Expand Down
5 changes: 5 additions & 0 deletions apps/qubit/modules/event/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class EventIndexAction extends sfAction
{
public function execute($request)
{
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}

$this->resource = $this->getRoute()->resource;

$value = array();
Expand Down
14 changes: 14 additions & 0 deletions apps/qubit/modules/function/actions/editAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,25 @@ protected function earlyExecute()
{
$this->resource = $this->getRoute()->resource;

// Check user authorization
if (!QubitAcl::check($this->resource, 'update') && !QubitAcl::check($this->resource, 'translate'))
{
QubitAcl::forwardUnauthorized();
}

// Add optimistic lock
$this->form->setDefault('serialNumber', $this->resource->serialNumber);
$this->form->setValidator('serialNumber', new sfValidatorInteger);
$this->form->setWidget('serialNumber', new sfWidgetFormInputHidden);
}
else
{
// Check authorization
if (!QubitAcl::check($this->parent, 'create'))
{
QubitAcl::forwardUnauthorized();
}
}
}

public function execute($request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,12 @@ protected function processForm()

public function execute($request)
{
// Force subclassing
if ('informationobject' == $this->context->getModuleName() && 'edit' == $this->context->getActionName())
{
$this->forward404();
}

parent::execute($request);

if ($request->hasParameter('csvimport'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public function execute($request)
$this->forward404();
}

// Check user authorization
if (!QubitAcl::check($this->resource, 'update'))
{
QubitAcl::forwardUnauthorized();
}

$criteria = new Criteria;
$criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
$criteria->add(QubitRelation::TYPE_ID, QubitTerm::HAS_PHYSICAL_OBJECT_ID);
Expand Down
10 changes: 9 additions & 1 deletion apps/qubit/modules/menu/config/security.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
list:
delete:
credentials: administrator
is_secure: true

edit:
credentials: administrator
is_secure: true

list:
credentials: administrator
is_secure: true
3 changes: 3 additions & 0 deletions apps/qubit/modules/physicalobject/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ delete:
edit:
credentials: [[ contributor, editor, administrator, translator ]]
is_secure: true

all:
is_secure: true
6 changes: 6 additions & 0 deletions apps/qubit/modules/relation/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class RelationIndexAction extends sfAction
{
public function execute($request)
{
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}

$this->resource = $this->getRoute()->resource;

$value = array();
Expand Down
12 changes: 12 additions & 0 deletions apps/qubit/modules/repository/actions/deleteAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public function execute($request)

$this->resource = $this->getRoute()->resource;

// Check that this isn't the root
if (!isset($this->resource->parent))
{
$this->forward404();
}

// Check user authorization
if (!QubitAcl::check($this->resource, 'delete'))
{
QubitAcl::forwardUnauthorized();
}

if ($request->isMethod('delete'))
{
foreach ($this->resource->informationObjects as $item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class RightsHolderAutocompleteAction extends sfAction
{
public function execute($request)
{
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}

if (!isset($request->limit))
{
$request->limit = sfConfig::get('app_hits_per_page');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class RightsHolderBrowseAction extends sfAction
{
public function execute($request)
{
if (!$this->context->user->hasCredential(array('contributor', 'editor', 'administrator'), false))
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class RightsHolderDeleteAction extends sfAction
{
public function execute($request)
{
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}

$this->form = new sfForm;

$this->resource = $this->getRoute()->resource;
Expand Down
3 changes: 2 additions & 1 deletion apps/qubit/modules/rightsholder/actions/listAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class RightsHolderListAction extends sfAction
{
public function execute($request)
{
if (!$this->context->user->hasCredential(array('contributor', 'editor', 'administrator'), false))
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}
Expand Down
8 changes: 8 additions & 0 deletions apps/qubit/modules/term/actions/editAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ protected function earlyExecute()

$title = $this->context->i18n->__('Edit %1%', array('%1%' => $title));
}
else
{
// Check authorization
if (!QubitAcl::check($this->resource, 'create'))
{
QubitAcl::forwardUnauthorized();
}
}

$this->response->setTitle("$title - {$this->response->getTitle()}");
}
Expand Down
22 changes: 22 additions & 0 deletions apps/qubit/modules/user/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,25 @@ passwordEdit:
update:
credentials: administrator
is_secure: true

indexTermAcl:
is_secure: true

indexRepositoryAcl:
is_secure: true

editActorAcl:
credentials: administrator
is_secure: true

editInformationObjectAcl:
credentials: administrator
is_secure: true

editRepositoryAcl:
credentials: administrator
is_secure: true

editTermAcl:
credentials: administrator
is_secure: true
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class DonorAutocompleteAction extends sfAction
{
public function execute($request)
{
// Check user authorization
if (!$this->getUser()->isAuthenticated())
{
QubitAcl::forwardUnauthorized();
}

if (!isset($request->limit))
{
$request->limit = sfConfig::get('app_hits_per_page');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public function execute($request)

$this->resource = $this->getRoute()->resource;

// Check user authorization
if (!QubitAcl::check($this->resource, 'delete'))
{
QubitAcl::forwardUnauthorized();
}

if ($request->isMethod('delete'))
{
foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item)
Expand Down

0 comments on commit d0a3711

Please sign in to comment.