-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applications: Transfer ownership #898
Comments
@juliushaertl @blizzz |
Once the Context is created the connected tables and views are untangled from the permissions of the owner. So that all should continue to work. So the feature spec. If it does not, it's a bug. |
I checked phpmyadmin, and the ownership is still with the original owner. And I'm unable to access tables from transfered contexts using the |
Untangled in the meaning that it table and view ownership or management permissions turn irrelevant (as long as the resource is connected to the Context) |
Oh I am starting to understand. Checking out your feature branch, the ownership is transferred. But obviously the resources cannot be loaded 🤦♂️ I understand all tables and views (at least their definitions) are loaded up front, for I do not see subsequent requests. Options:
What's your take? |
I was trying this out. I couldn't use the |
That's on me, on the backend side. |
Please try with this patch as quick fix: diff --git a/lib/Service/PermissionsService.php b/lib/Service/PermissionsService.php
index 922bd468..2789d5ae 100644
--- a/lib/Service/PermissionsService.php
+++ b/lib/Service/PermissionsService.php
@@ -242,7 +242,20 @@ class PermissionsService {
public function canReadColumnsByTableId(int $tableId, ?string $userId = null): bool {
$canReadRows = $this->checkPermissionById($tableId, 'table', 'read', $userId);
$canCreateRows = $this->checkPermissionById($tableId, 'table', 'create', $userId);
- return $canCreateRows || $canReadRows;
+ if ($canReadRows || $canCreateRows) {
+ return true;
+ }
+
+ $contexts = $this->contextMapper->findAll($userId ?? $this->userId);
+ foreach ($contexts as $context) {
+ $nodes = $context->getNodes();
+ foreach ($nodes as $node) {
+ if ((int)$node['node_type'] === Application::NODE_TYPE_TABLE && $node['node_id'] === $tableId) {
+ return true;
+ }
+ }
+ }
+ return false;
}
/**
@@ -553,7 +566,23 @@ class PermissionsService {
try {
$element = $nodeType === 'table' ? $this->tableMapper->find($elementId) : $this->viewMapper->find($elementId);
- return $this->basisCheck($element, $nodeType, $userId);
+ if ($this->basisCheck($element, $nodeType, $userId)) {
+ return true;
+ }
+ $contextMapper = \OCP\Server::get(ContextMapper::class);
+ $contexts = $contextMapper->findAll($userId ?? $this->userId);
+ foreach ($contexts as $context) {
+ $nodes = $context->getNodes();
+ foreach ($nodes as $node) {
+ if ($nodeType === 'table' && (int)$node['node_type'] === Application::NODE_TYPE_TABLE && $node['node_id'] === $elementId) {
+ return true;
+ }
+ if ($nodeType === 'view' && (int)$node['node_type'] === Application::NODE_TYPE_VIEW && $node['node_id'] === $elementId) {
+ return true;
+ }
+ }
+ }
+ // FIXME: avoid duplications
} catch (DoesNotExistException|MultipleObjectsReturnedException|\Exception $e) {
$this->logger->warning('Exception occurred: '.$e->getMessage());
} I could not test yet, and a call is approaching. |
Updated the patch, but it is probably not sufficient. Need to have a better look at the Permissions tomorrow. |
The text was updated successfully, but these errors were encountered: