mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-07 22:53:45 -06:00
Ensure that a user can connect to a server using SSL certificates and identity files from a shared storage. #7306
This commit is contained in:
parent
c47390e643
commit
fff192eb95
@ -165,6 +165,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
|||||||
server.tunnel_username = sharedserver.tunnel_username
|
server.tunnel_username = sharedserver.tunnel_username
|
||||||
server.tunnel_password = sharedserver.tunnel_password
|
server.tunnel_password = sharedserver.tunnel_password
|
||||||
server.save_password = sharedserver.save_password
|
server.save_password = sharedserver.save_password
|
||||||
|
server.tunnel_identity_file = sharedserver.tunnel_identity_file
|
||||||
if hasattr(server, 'connection_params') and \
|
if hasattr(server, 'connection_params') and \
|
||||||
hasattr(sharedserver, 'connection_params') and \
|
hasattr(sharedserver, 'connection_params') and \
|
||||||
'passfile' in server.connection_params and \
|
'passfile' in server.connection_params and \
|
||||||
|
@ -43,6 +43,7 @@ import { withColorPicker } from '../helpers/withColorPicker';
|
|||||||
import { useWindowSize } from '../custom_hooks';
|
import { useWindowSize } from '../custom_hooks';
|
||||||
import PgTreeView from '../PgTreeView';
|
import PgTreeView from '../PgTreeView';
|
||||||
import Loader from 'sources/components/Loader';
|
import Loader from 'sources/components/Loader';
|
||||||
|
import { MY_STORAGE } from '../../../misc/file_manager/static/js/components/FileManagerConstants';
|
||||||
|
|
||||||
|
|
||||||
const Root = styled('div')(({theme}) => ({
|
const Root = styled('div')(({theme}) => ({
|
||||||
@ -459,8 +460,12 @@ export function InputFileSelect({ controlProps, onChange, disabled, readonly, is
|
|||||||
dialog_title: controlProps.dialogTitle || '',
|
dialog_title: controlProps.dialogTitle || '',
|
||||||
btn_primary: controlProps.btnPrimary || '',
|
btn_primary: controlProps.btnPrimary || '',
|
||||||
};
|
};
|
||||||
showFileManager(params, (fileName)=>{
|
showFileManager(params, (fileName, dir)=>{
|
||||||
onChange?.(decodeURI(fileName));
|
if (dir && dir != MY_STORAGE){
|
||||||
|
onChange?.(dir + ':' + decodeURI(fileName));
|
||||||
|
}else{
|
||||||
|
onChange?.(decodeURI(fileName));
|
||||||
|
}
|
||||||
inpRef.current.focus();
|
inpRef.current.focus();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
@ -211,6 +212,25 @@ else:
|
|||||||
return os.path.realpath(os.path.expanduser('~/'))
|
return os.path.realpath(os.path.expanduser('~/'))
|
||||||
|
|
||||||
|
|
||||||
|
def get_directory_and_file_name(drivefilepath):
|
||||||
|
"""
|
||||||
|
Returns directory name if specified and file name
|
||||||
|
:param drivefilepath: file path like '<shared_drive_name>:/filename' or
|
||||||
|
'/filename'
|
||||||
|
:return: directory name and file name
|
||||||
|
"""
|
||||||
|
dir_name = ''
|
||||||
|
file_name = drivefilepath
|
||||||
|
if config.SHARED_STORAGE:
|
||||||
|
shared_dirs = [sdir['name'] + ':' for sdir in config.SHARED_STORAGE]
|
||||||
|
if len(re.findall(r"(?=(" + '|'.join(shared_dirs) + r"))",
|
||||||
|
drivefilepath)) > 0:
|
||||||
|
dir_file_paths = drivefilepath.split(':/')
|
||||||
|
dir_name = dir_file_paths[0]
|
||||||
|
file_name = dir_file_paths[1]
|
||||||
|
return dir_name, file_name
|
||||||
|
|
||||||
|
|
||||||
def get_complete_file_path(file, validate=True):
|
def get_complete_file_path(file, validate=True):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
@ -226,7 +246,11 @@ def get_complete_file_path(file, validate=True):
|
|||||||
if current_app.PGADMIN_RUNTIME or not current_app.config['SERVER_MODE']:
|
if current_app.PGADMIN_RUNTIME or not current_app.config['SERVER_MODE']:
|
||||||
return file if os.path.isfile(file) else None
|
return file if os.path.isfile(file) else None
|
||||||
|
|
||||||
storage_dir = get_storage_directory()
|
# get dir name and file name
|
||||||
|
dir_name, file = get_directory_and_file_name(file)
|
||||||
|
|
||||||
|
storage_dir = get_storage_directory(shared_storage=dir_name) if dir_name \
|
||||||
|
else get_storage_directory()
|
||||||
if storage_dir:
|
if storage_dir:
|
||||||
file = os.path.join(
|
file = os.path.join(
|
||||||
storage_dir,
|
storage_dir,
|
||||||
@ -246,12 +270,15 @@ def filename_with_file_manager_path(_file, create_file=False,
|
|||||||
skip_permission_check=False):
|
skip_permission_check=False):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
file: File name returned from client file manager
|
_file: File name returned from client file manager
|
||||||
create_file: Set flag to False when file creation doesn't require
|
create_file: Set flag to False when file creation doesn't require
|
||||||
skip_permission_check:
|
skip_permission_check:
|
||||||
Returns:
|
Returns:
|
||||||
Filename to use for backup with full path taken from preference
|
Filename to use for backup with full path taken from preference
|
||||||
"""
|
"""
|
||||||
|
# get dir name and file name
|
||||||
|
_dir_name, _file = get_directory_and_file_name(_file)
|
||||||
|
|
||||||
# retrieve storage directory path
|
# retrieve storage directory path
|
||||||
try:
|
try:
|
||||||
last_storage = Preferences.module('file_manager').preference(
|
last_storage = Preferences.module('file_manager').preference(
|
||||||
|
Loading…
Reference in New Issue
Block a user