diff --git a/appinfo/routes.php b/appinfo/routes.php index 510e687f..4fadef94 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -59,6 +59,7 @@ return [ ['name' => 'share#getPublicCredentialData', 'url' => '/api/v2/sharing/credential/{credential_guid}/public', 'verb' => 'GET'], ['name' => 'share#unshareCredential', 'url' => '/api/v2/sharing/credential/{item_guid}', 'verb' => 'DELETE'], ['name' => 'share#getRevisions', 'url' => '/api/v2/sharing/credential/{item_guid}/revisions', 'verb' => 'GET'], + ['name' => 'share#getItemAcl', 'url' => '/api/v2/sharing/credential/{item_guid}/acl', 'verb' => 'GET'], //Internal API ['name' => 'internal#remind', 'url' => '/api/internal/notifications/remind/{credential_id}', 'verb' => 'POST'], diff --git a/controller/sharecontroller.php b/controller/sharecontroller.php index 2cc815b0..8acfe1fe 100644 --- a/controller/sharecontroller.php +++ b/controller/sharecontroller.php @@ -322,4 +322,20 @@ class ShareController extends ApiController { return new NotFoundResponse(); } } + + public function getItemAcl($item_guid){ + $acl = $this->shareService->getCredentialAclList($item_guid); + try { + $credential = $this->credentialService->getCredentialByGUID($item_guid); + if ($credential->getUserId() == $this->userId){ + return new JSONResponse($acl); + } + else{ + return new NotFoundResponse(); + } + } + catch (DoesNotExistException $ex){ + return new NotFoundResponse(); + } + } } \ No newline at end of file diff --git a/lib/Db/CredentialMapper.php b/lib/Db/CredentialMapper.php index 601827fd..8bb35c29 100644 --- a/lib/Db/CredentialMapper.php +++ b/lib/Db/CredentialMapper.php @@ -134,4 +134,14 @@ class CredentialMapper extends Mapper { public function upd(Credential $credential){ $this->update($credential); } + + /** + * Finds a credential by the given guid + * @param $credential_guid + * @return Credential + */ + public function getCredentialByGUID($credential_guid){ + $q = 'SELECT * FROM `*PREFIX*passman_credentials` WHERE guid = ? '; + return $this->findEntity($q, [$credential_guid]); + } } \ No newline at end of file diff --git a/lib/Service/CredentialService.php b/lib/Service/CredentialService.php index b9b9c92c..e6868f9a 100644 --- a/lib/Service/CredentialService.php +++ b/lib/Service/CredentialService.php @@ -73,4 +73,8 @@ class CredentialService { public function getCredentialLabelById($credential_id){ return $this->credentialMapper->getCredentialLabelById($credential_id); } + + public function getCredentialByGUID($credential_guid){ + return $this->credentialMapper->getCredentialByGUID($credential_guid); + } } \ No newline at end of file