connections per role

This commit is contained in:
Jan Prochazka 2024-07-30 16:26:02 +02:00
parent 2c805b3357
commit 4c5da50a04
6 changed files with 10 additions and 7 deletions

View File

@ -71,6 +71,7 @@ module.exports = {
{
login: 'superadmin',
permissions: await storage.loadSuperadminPermissions(),
roleId: -3,
},
getTokenSecret(),
{

View File

@ -201,7 +201,7 @@ module.exports = {
async list(_params, req) {
const storage = require('./storage');
const storageConnections = await storage.connections();
const storageConnections = await storage.connections(req);
if (storageConnections) {
return storageConnections;
}

View File

@ -1,6 +1,6 @@
module.exports = {
connections_meta: true,
async connections() {
async connections(req) {
return null;
},

View File

@ -101,11 +101,11 @@ export function testSubPermission(
export function getPredefinedPermissions(predefinedRoleName: string) {
switch (predefinedRoleName) {
case 'superadmin':
return ['*', '~widgets/*', 'widgets/admin'];
return ['*', '~widgets/*', 'widgets/admin', '~all-connections'];
case 'logged-user':
return ['*', '~widgets/admin', '~admin/*'];
return ['*', '~widgets/admin', '~admin/*', '~internal-storage', '~all-connections'];
case 'anonymous-user':
return ['*', '~widgets/admin', '~admin/*'];
return ['*', '~widgets/admin', '~admin/*', '~internal-storage', '~all-connections'];
default:
return null;
}

View File

@ -104,7 +104,7 @@ registerCommand({
category: 'New',
toolbarOrder: 1,
name: 'Connection',
testEnabled: () => !getCurrentConfig()?.runAsPortal,
testEnabled: () => !getCurrentConfig()?.runAsPortal && !getCurrentConfig()?.storageDatabase,
onClick: () => {
openNewTab({
title: 'New Connection',

View File

@ -2,6 +2,7 @@ import _ from 'lodash';
import { openedConnections, currentDatabase, openedConnectionsWithTemporary, getCurrentConfig } from '../stores';
import { apiCall, strmid } from './api';
import { getConnectionList } from './metadataLoaders';
import hasPermission from '../utility/hasPermission';
// const doServerPing = async value => {
// const connectionList = getConnectionList();
@ -11,7 +12,8 @@ import { getConnectionList } from './metadataLoaders';
const doServerPing = value => {
apiCall('server-connections/ping', {
conidArray: getCurrentConfig().storageDatabase ? ['__storage', ...value] : value,
conidArray:
getCurrentConfig().storageDatabase && hasPermission('internal-storage') ? ['__storage', ...value] : value,
strmid,
});
};