Skip to content
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

[full-ci] feature-deny-access #8983

Merged
merged 12 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,7 @@ def ocisService():
"WEB_ASSET_PATH": "%s/dist" % dir["web"],
"WEB_UI_CONFIG": "%s" % dir["ocisConfig"],
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"FRONTEND_OCS_ENABLE_DENIALS": True,
},
"commands": [
"cd %s" % dir["ocis"],
Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/enhancement-deny-share-access
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: deny share access

We've added a way to deny the share access in sub folders in a share or space.
This allows the share editors to restrict access to certain resources within a share for certain share receivers.

https://github.com/owncloud/web/pull/8983
https://github.com/owncloud/web/issues/7180

2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ services:

#FRONTEND
FRONTEND_SEARCH_MIN_LENGTH: "2"
FRONTEND_OCS_ENABLE_DENIALS: "true"

# IDM
IDM_CREATE_DEMO_USERS: "${DEMO_USERS:-true}"
IDM_ADMIN_PASSWORD: "${ADMIN_PASSWORD:-admin}" # override the random admin password from `ocis init`
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/src/components/OcDrop/OcDrop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export default defineComponent({
}
li.oc-menu-item-hover {
a,
.item-has-switch,
button:not([role='switch']) {
box-sizing: border-box;
padding: var(--oc-space-small);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,32 @@
</oc-datepicker>
</li>
<li v-for="(option, i) in options" :key="i" class="oc-rounded oc-menu-item-hover">
<oc-button
v-if="option.enabled"
appearance="raw"
class="oc-p-s action-menu-item"
:class="option.class"
v-bind="option.additionalAttributes || {}"
@click="option.method()"
>
<oc-icon :name="option.icon" fill-type="line" size="medium" variation="passive" />
<span v-text="option.title" />
</oc-button>
<template v-if="option.enabled">
<div
v-if="option.hasSwitch"
class="action-menu-item item-has-switch oc-p-s oc-flex oc-flex-center"
>
<oc-icon :name="option.icon" fill-type="line" size="medium" variation="passive" />
<oc-switch
class="oc-ml-s oc-flex oc-width-1-1 oc-button-justify-content-space-between"
:checked="isShareDenied"
:class="option.class"
:label="option.title"
@update:checked="option.method"
/>
</div>
<oc-button
v-else
appearance="raw"
class="oc-p-s action-menu-item"
:class="option.class"
v-bind="option.additionalAttributes || {}"
@click="option.method"
>
<oc-icon :name="option.icon" fill-type="line" size="medium" variation="passive" />
<span class="oc-ml-s" v-text="option.title" />
</oc-button>
</template>
</li>
</oc-list>
</oc-drop>
Expand Down Expand Up @@ -80,12 +95,25 @@ export default defineComponent({
canEditOrDelete: {
type: Boolean,
required: true
},
isShareDenied: {
type: Boolean,
default: false
},
deniable: {
type: Boolean,
default: false
}
},
emits: ['expirationDateChanged', 'removeShare', 'showAccessDetails'],
setup() {
emits: ['expirationDateChanged', 'removeShare', 'showAccessDetails', 'setDenyShare'],
setup(props, { emit }) {
const toggleShareDenied = (value) => {
emit('setDenyShare', value)
}

return {
resource: inject<Ref<Resource>>('resource')
resource: inject<Ref<Resource>>('resource'),
toggleShareDenied
}
},
data: function () {
Expand Down Expand Up @@ -130,6 +158,14 @@ export default defineComponent({
enabled: true,
icon: 'information',
class: 'show-access-details'
},
{
title: this.$gettext('Deny access'),
method: this.toggleShareDenied,
enabled: this.deniable,
icon: 'stop-circle',
class: 'deny-share',
hasSwitch: true
}
]
},
Expand Down Expand Up @@ -266,5 +302,7 @@ export default defineComponent({
.collaborator-edit-dropdown-options-list .action-menu-item {
width: 100%;
justify-content: flex-start;
color: var(--oc-color-swatch-passive-default);
gap: var(--oc-space-small);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ import {
} from 'web-client/src/helpers/share'
import {
useCapabilityFilesSharingAllowCustomPermissions,
useCapabilityFilesSharingCanDenyAccess,
useCapabilityFilesSharingResharing,
useCapabilityFilesSharingResharingDefault,
useCapabilityShareJailEnabled,
Expand Down Expand Up @@ -133,7 +132,6 @@ export default defineComponent({
resharingDefault: useCapabilityFilesSharingResharingDefault(store),
hasShareJail: useCapabilityShareJailEnabled(store),
hasRoleCustomPermissions: useCapabilityFilesSharingAllowCustomPermissions(store),
hasRoleDenyAccess: useCapabilityFilesSharingCanDenyAccess(store),
clientService,
...useShares()
}
Expand Down Expand Up @@ -181,16 +179,15 @@ export default defineComponent({
if (this.resourceIsSpace) {
this.selectedRole = SpacePeopleShareRoles.list()[0]
} else {
const canDeny = this.resource.canDeny() && this.hasRoleDenyAccess
this.selectedRole = PeopleShareRoles.list(
this.resource.isFolder,
this.hasRoleCustomPermissions,
canDeny
this.hasRoleCustomPermissions
)[0]
}
},

methods: {
...mapActions(['showMessage']),
...mapActions('Files', ['addShare']),
...mapActions('runtime/spaces', ['addSpaceMember']),

Expand Down Expand Up @@ -300,12 +297,13 @@ export default defineComponent({

async share() {
this.saving = true
const errors = []

const saveQueue = new PQueue({ concurrency: 4 })
const savePromises = []
this.selectedCollaborators.forEach((collaborator) => {
savePromises.push(
saveQueue.add(() => {
saveQueue.add(async () => {
const bitmask = this.selectedRole.hasCustomPermissions
? SharePermissions.permissionsToBitmask(this.customPermissions)
: SharePermissions.permissionsToBitmask(
Expand All @@ -321,24 +319,46 @@ export default defineComponent({
}

const addMethod = this.resourceIsSpace ? this.addSpaceMember : this.addShare
addMethod({
...this.$language,
client: this.$client,
graphClient: this.clientService.graphAuthenticated,
path,
shareWith: collaborator.value.shareWith,
displayName: collaborator.label,
shareType: collaborator.value.shareType,
permissions: bitmask,
role: this.selectedRole,
expirationDate: this.expirationDate,
storageId: this.resource.fileId || this.resource.id
})

try {
await addMethod({
client: this.$client,
graphClient: this.clientService.graphAuthenticated,
path,
shareWith: collaborator.value.shareWith,
displayName: collaborator.label,
shareType: collaborator.value.shareType,
permissions: bitmask,
role: this.selectedRole,
expirationDate: this.expirationDate,
storageId: this.resource.fileId || this.resource.id
})
} catch (e) {
console.error(e)
errors.push({
displayName: collaborator.label,
error: e
})
throw e
}
})
)
})

await Promise.all(savePromises)
const results = await Promise.allSettled(savePromises)

if (results.length !== errors.length) {
this.showMessage({ title: this.$gettext('Share was added successfully') })
}
errors.forEach((e) => {
this.showMessage({
title: this.$gettext('Failed to add share for %{displayName}', {
displayName: e.displayName
}),
status: 'danger'
})
})

this.selectedCollaborators = []
this.saving = false
},
Expand Down
Loading