mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: new security / permissions
This commit is contained in:
+1
-1
@@ -184,7 +184,7 @@
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Permissions</Heading>
|
||||
<p>
|
||||
<p class="text">
|
||||
Choose who can access your collection and documents. For more information, check out
|
||||
the <a
|
||||
href="https://appwrite.io/docs/permissions"
|
||||
|
||||
+59
-40
@@ -54,14 +54,10 @@
|
||||
encryption ??= $bucket.encryption;
|
||||
antivirus ??= $bucket.antivirus;
|
||||
});
|
||||
$: if (bucketFileSecurity || bucketPermissions) {
|
||||
if (bucketFileSecurity !== $bucket.fileSecurity) {
|
||||
$: if (bucketPermissions) {
|
||||
if (symmetricDifference(bucketPermissions, $bucket.$permissions).length) {
|
||||
arePermsDisabled = false;
|
||||
} else if (bucketPermissions) {
|
||||
if (symmetricDifference(bucketPermissions, $bucket.$permissions).length) {
|
||||
arePermsDisabled = false;
|
||||
} else arePermsDisabled = true;
|
||||
}
|
||||
} else arePermsDisabled = true;
|
||||
}
|
||||
$: if (extensions) {
|
||||
if (JSON.stringify(extensions) !== JSON.stringify($bucket.allowedFileExtensions)) {
|
||||
@@ -106,17 +102,33 @@
|
||||
}
|
||||
}
|
||||
async function updatePermissions() {
|
||||
try {
|
||||
await sdkForProject.storage.updateBucket($bucket.$id, $bucket.name, bucketPermissions);
|
||||
invalidate(Dependencies.BUCKET);
|
||||
arePermsDisabled = true;
|
||||
addNotification({
|
||||
message: 'Permissions have been updated',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
async function updateFileSecurity() {
|
||||
try {
|
||||
await sdkForProject.storage.updateBucket(
|
||||
$bucket.$id,
|
||||
$bucket.name,
|
||||
bucketFileSecurity ? bucketPermissions : undefined,
|
||||
$bucket.$permissions,
|
||||
bucketFileSecurity
|
||||
);
|
||||
invalidate(Dependencies.BUCKET);
|
||||
arePermsDisabled = true;
|
||||
addNotification({
|
||||
message: 'Permissions have been updated',
|
||||
message: 'Security has been updated',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -242,8 +254,9 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={bucketName === $bucket.name || !bucketName} submit
|
||||
>Update</Button>
|
||||
<Button disabled={bucketName === $bucket.name || !bucketName} submit>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -251,37 +264,15 @@
|
||||
<Form on:submit={updatePermissions}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Permissions</Heading>
|
||||
<p>
|
||||
Assign read or write permissions at the <b>Bucket Level</b> or
|
||||
<b>File Level</b>. If Bucket Level permissions are assigned, file permissions
|
||||
will be ignored.
|
||||
<p class="text">
|
||||
Choose who can access your buckets and files. For more information, check out
|
||||
the <a
|
||||
href="https://appwrite.io/docs/permissions"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">Permissions Guide</a> in our documentation.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<ul class="checkboxes-list">
|
||||
<li class="checkboxes-item">
|
||||
<label class="label">
|
||||
<input
|
||||
type="radio"
|
||||
class="is-small"
|
||||
name="level"
|
||||
bind:group={bucketFileSecurity}
|
||||
value={true} />
|
||||
<span>Bucket Level</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="checkboxes-item">
|
||||
<label class="label">
|
||||
<input
|
||||
type="radio"
|
||||
class="is-small"
|
||||
name="level"
|
||||
bind:group={bucketFileSecurity}
|
||||
value={false} />
|
||||
<span>File Level</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
{#if bucketFileSecurity}
|
||||
{#if bucketPermissions}
|
||||
<Permissions bind:permissions={bucketPermissions} />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
@@ -291,6 +282,34 @@
|
||||
</CardGrid>
|
||||
</Form>
|
||||
|
||||
<Form on:submit={updateFileSecurity}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update File Security</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputSwitch
|
||||
bind:value={bucketFileSecurity}
|
||||
id="security"
|
||||
label="File Security" />
|
||||
</FormList>
|
||||
<p class="text">
|
||||
When file security is enabled, users will be able to access files for which
|
||||
they have been granted <b>either File or Bucket permissions</b>.
|
||||
</p>
|
||||
<p class="text">
|
||||
If file security is disabled, users can access files <b
|
||||
>only if they have Bucket permissions</b
|
||||
>. File permissions will be ignored..
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={bucketFileSecurity === $bucket.fileSecurity} submit>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
|
||||
<Form on:submit={updateSecurity}>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="7">Update Security Settings</Heading>
|
||||
|
||||
Reference in New Issue
Block a user