Skip to content

Commit

Permalink
Merge pull request #5497 from appwrite/fix-bucket-permissions
Browse files Browse the repository at this point in the history
Fix bucket permissions
  • Loading branch information
TorstenDittmann committed May 4, 2023
2 parents 25b1eb0 + d7bbfb5 commit 67ad856
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 1.3.4

## Bugs

- Update migration to properly migrate bucket permissiosn [#5497](https://github.com/appwrite/appwrite/pull/5497)

# Version 1.3.3

## Bugs
Expand Down
6 changes: 3 additions & 3 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.3.3
appwrite/appwrite:1.3.4
```

### Windows
Expand All @@ -78,7 +78,7 @@ docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.3.3
appwrite/appwrite:1.3.4
```

#### PowerShell
Expand All @@ -88,7 +88,7 @@ docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.3.3
appwrite/appwrite:1.3.4
```

运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.3.3
appwrite/appwrite:1.3.4
```

### Windows
Expand All @@ -87,7 +87,7 @@ docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.3.3
appwrite/appwrite:1.3.4
```

#### PowerShell
Expand All @@ -97,7 +97,7 @@ docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.3.3
appwrite/appwrite:1.3.4
```

Once the Docker installation is complete, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after completing the installation.
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

$bucket = $dbForProject->getDocument('buckets', $bucketId);

$dbForProject->createCollection('bucket_' . $bucket->getInternalId(), $attributes, $indexes);
$dbForProject->createCollection('bucket_' . $bucket->getInternalId(), $attributes, $indexes, permissions: $permissions ?? [], documentSecurity: $fileSecurity);
} catch (Duplicate) {
throw new Exception(Exception::STORAGE_BUCKET_ALREADY_EXISTS);
}
Expand Down Expand Up @@ -274,6 +274,7 @@
->setAttribute('encryption', $encryption)
->setAttribute('compression', $compression)
->setAttribute('antivirus', $antivirus));
$dbForProject->updateCollection('bucket_' . $bucket->getInternalId(), $permissions, $fileSecurity);

$events
->setParam('bucketId', $bucket->getId())
Expand Down
2 changes: 1 addition & 1 deletion app/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
const APP_KEY_ACCCESS = 24 * 60 * 60; // 24 hours
const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours
const APP_CACHE_BUSTER = 503;
const APP_VERSION_STABLE = '1.3.3';
const APP_VERSION_STABLE = '1.3.4';
const APP_DATABASE_ATTRIBUTE_EMAIL = 'email';
const APP_DATABASE_ATTRIBUTE_ENUM = 'enum';
const APP_DATABASE_ATTRIBUTE_IP = 'ip';
Expand Down
1 change: 1 addition & 0 deletions src/Appwrite/Migration/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ abstract class Migration
'1.3.1' => 'V18',
'1.3.2' => 'V18',
'1.3.3' => 'V18',
'1.3.4' => 'V18',
];

/**
Expand Down
13 changes: 13 additions & 0 deletions src/Appwrite/Migration/Version/V18.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@ protected function fixDocument(Document $document): Document
*/
$document->setAttribute('options', $document->getAttribute('options', new \stdClass()));
break;
case 'buckets':
/**
* Set the bucket permission in the metadata table
*/
try {
$internalBucketId = "bucket_{$this->project->getInternalId()}";
$permissions = $document->getPermissions();
$fileSecurity = $document->getAttribute('fileSecurity', false);
$this->projectDB->updateCollection($internalBucketId, $permissions, $fileSecurity);
} catch (\Throwable $th) {
Console::warning($th->getMessage());
}
break;
}

return $document;
Expand Down

0 comments on commit 67ad856

Please sign in to comment.