Browse Source

fix: permission correction

pull/8708/head
Pranav C 6 months ago
parent
commit
17bbfd3532
  1. 2
      packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue
  2. 32
      packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue
  3. 38
      packages/nocodb/src/utils/acl.ts

2
packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue

@ -104,7 +104,7 @@ const showBaseOption = (source: SourceType) => {
return ['airtableImport', 'csvImport', 'jsonImport', 'excelImport'].some((permission) => return ['airtableImport', 'csvImport', 'jsonImport', 'excelImport'].some((permission) =>
isUIAllowed(permission, { source }), isUIAllowed(permission, { source }),
) )
}) }
const enableEditMode = () => { const enableEditMode = () => {
editMode.value = true editMode.value = true

32
packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue

@ -56,9 +56,8 @@ const formState = ref<ProjectCreateForm>({
}, },
sslUse: SSLUsage.No, sslUse: SSLUsage.No,
extraParameters: [], extraParameters: [],
'is_schema_readonly': true, is_schema_readonly: true,
'is_data_readonly': false, is_data_readonly: false,
},
}) })
const customFormState = ref<ProjectCreateForm>({ const customFormState = ref<ProjectCreateForm>({
@ -516,8 +515,7 @@ const allowDataWrite = computed({
<!-- Username --> <!-- Username -->
<a-form-item :label="$t('labels.username')" v-bind="validateInfos['dataSource.connection.user']"> <a-form-item :label="$t('labels.username')" v-bind="validateInfos['dataSource.connection.user']">
<a-input v-model:value="(formState.dataSource.connection as DefaultConnection).user" <a-input v-model:value="(formState.dataSource.connection as DefaultConnection).user" class="nc-extdb-host-user" />
class="nc-extdb-host-user"/>
</a-form-item> </a-form-item>
<!-- Password --> <!-- Password -->
@ -593,8 +591,7 @@ const allowDataWrite = computed({
<div class="flex items-right justify-end gap-2"> <div class="flex items-right justify-end gap-2">
<!-- Use Connection URL --> <!-- Use Connection URL -->
<NcButton type="ghost" size="small" class="nc-extdb-btn-import-url !rounded-md" <NcButton type="ghost" size="small" class="nc-extdb-btn-import-url !rounded-md" @click.stop="importURLDlg = true">
@click.stop="importURLDlg = true">
{{ $t('activity.useConnectionUrl') }} {{ $t('activity.useConnectionUrl') }}
</NcButton> </NcButton>
</div> </div>
@ -632,8 +629,7 @@ const allowDataWrite = computed({
<span>{{ $t('tooltip.clientCert') }}</span> <span>{{ $t('tooltip.clientCert') }}</span>
</template> </template>
<NcButton size="small" :disabled="!sslFilesRequired" class="shadow" <NcButton size="small" :disabled="!sslFilesRequired" class="shadow" @click="certFileInput?.click()">
@click="certFileInput?.click()">
{{ $t('labels.clientCert') }} {{ $t('labels.clientCert') }}
</NcButton> </NcButton>
</a-tooltip> </a-tooltip>
@ -643,8 +639,7 @@ const allowDataWrite = computed({
<template #title> <template #title>
<span>{{ $t('tooltip.clientKey') }}</span> <span>{{ $t('tooltip.clientKey') }}</span>
</template> </template>
<NcButton size="small" :disabled="!sslFilesRequired" class="shadow" <NcButton size="small" :disabled="!sslFilesRequired" class="shadow" @click="keyFileInput?.click()">
@click="keyFileInput?.click()">
{{ $t('labels.clientKey') }} {{ $t('labels.clientKey') }}
</NcButton> </NcButton>
</a-tooltip> </a-tooltip>
@ -655,22 +650,18 @@ const allowDataWrite = computed({
<span>{{ $t('tooltip.clientCA') }}</span> <span>{{ $t('tooltip.clientCA') }}</span>
</template> </template>
<NcButton size="small" :disabled="!sslFilesRequired" class="shadow" <NcButton size="small" :disabled="!sslFilesRequired" class="shadow" @click="caFileInput?.click()">
@click="caFileInput?.click()">
{{ $t('labels.serverCA') }} {{ $t('labels.serverCA') }}
</NcButton> </NcButton>
</a-tooltip> </a-tooltip>
</div> </div>
</a-form-item> </a-form-item>
<input ref="caFileInput" type="file" class="!hidden" <input ref="caFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.ca, caFileInput)" />
@change="onFileSelect(CertTypes.ca, caFileInput)"/>
<input ref="certFileInput" type="file" class="!hidden" <input ref="certFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.cert, certFileInput)" />
@change="onFileSelect(CertTypes.cert, certFileInput)"/>
<input ref="keyFileInput" type="file" class="!hidden" <input ref="keyFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.key, keyFileInput)" />
@change="onFileSelect(CertTypes.key, keyFileInput)"/>
<a-divider /> <a-divider />
@ -729,8 +720,7 @@ const allowDataWrite = computed({
v-model:value="formState.inflection.inflectionColumn" v-model:value="formState.inflection.inflectionColumn"
dropdown-class-name="nc-dropdown-inflection-column-name" dropdown-class-name="nc-dropdown-inflection-column-name"
> >
<a-select-option v-for="tp in inflectionTypes" :key="tp" :value="tp" <a-select-option v-for="tp in inflectionTypes" :key="tp" :value="tp">
>
<div class="flex items-center gap-2 justify-between"> <div class="flex items-center gap-2 justify-between">
<div>{{ tp }}</div> <div>{{ tp }}</div>
<component <component

38
packages/nocodb/src/utils/acl.ts

@ -450,28 +450,34 @@ Object.values(rolePermissions).forEach((role) => {
} }
}); });
// excluded/restricted permissions at source level based on source restriction // Excluded permissions for source restrictions
// `true` means permission is restricted and `false`/missing means permission is allowed // `true` means permission is restricted and `false`/missing means permission is allowed
export const sourceRestrictions = { export const sourceRestrictions = {
[SourceRestriction.DATA_READONLY]: {
dataInsert: true,
dataEdit: true,
dataDelete: true,
airtableImport: true,
csvImport: true,
jsonImport: true,
excelImport: true,
},
[SourceRestriction.SCHEMA_READONLY]: { [SourceRestriction.SCHEMA_READONLY]: {
tableCreate: true, tableCreate: true,
tableRename: true,
tableDelete: true, tableDelete: true,
tableDuplicate: true, tableUpdate: true,
airtableImport: true, // columnAdd: true,
csvImport: true, // columnDelete: true,
jsonImport: true, // columnUpdate: true,
excelImport: true, columnBulk: true,
},
[SourceRestriction.DATA_READONLY]: {
dataUpdate: true,
dataDelete: true,
dataInsert: true,
bulkDataInsert: true,
bulkDataUpdate: true,
bulkDataUpdateAll: true,
bulkDataDelete: true,
bulkDataDeleteAll: true,
relationDataRemove: true,
relationDataAdd: true,
nestedDataListCopyPasteOrDeleteAll: true,
nestedDataUnlink: true,
nestedDataLink: true,
}, },
}; };
export default rolePermissions; export default rolePermissions;

Loading…
Cancel
Save