Server config information in the about dialog should be only visible to admin users. #6769

pull/6929/head
Pravesh Sharma 2023-11-03 14:37:25 +05:30 committed by GitHub
parent 9eb7c1cbea
commit 01d1e6f706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 52 deletions

View File

@ -59,46 +59,50 @@ def index():
info = {}
# Get OS , NW.js, Browser details
browser, os_details, nwjs_version = detect_browser(request)
admin = is_admin(current_user.email)
if nwjs_version:
info['nwjs'] = nwjs_version
info['browser_details'] = browser
info['os_details'] = os_details
info['config_db'] = config.SQLITE_PATH
info['log_file'] = config.LOG_FILE
info['version'] = config.APP_VERSION
if config.SERVER_MODE:
info['app_mode'] = gettext('Server')
admin = is_admin(current_user.email)
info['admin'] = admin
else:
info['app_mode'] = gettext('Desktop')
info['browser_details'] = browser
info['version'] = config.APP_VERSION
info['admin'] = admin
info['current_user'] = current_user.email
settings = ""
for setting in dir(config):
if not setting.startswith('_') and setting.isupper() and \
setting not in ['CSRF_SESSION_KEY',
'SECRET_KEY',
'SECURITY_PASSWORD_SALT',
'SECURITY_PASSWORD_HASH',
'ALLOWED_HOSTS',
'MAIL_PASSWORD',
'LDAP_BIND_PASSWORD',
'SECURITY_PASSWORD_HASH']:
if isinstance(getattr(config, setting), str):
settings = \
settings + '{} = "{}"\n'.format(
setting, getattr(config, setting))
else:
settings = \
settings + '{} = {}\n'.format(
setting, getattr(config, setting))
if admin:
settings = ""
info['os_details'] = os_details
info['log_file'] = config.LOG_FILE
info['settings'] = settings
# If external datbase is used do not display SQLITE_PATH
if not config.CONFIG_DATABASE_URI:
info['config_db'] = config.SQLITE_PATH
for setting in dir(config):
if not setting.startswith('_') and setting.isupper() and \
setting not in ['CSRF_SESSION_KEY',
'SECRET_KEY',
'SECURITY_PASSWORD_SALT',
'SECURITY_PASSWORD_HASH',
'ALLOWED_HOSTS',
'MAIL_PASSWORD',
'LDAP_BIND_PASSWORD',
'SECURITY_PASSWORD_HASH']:
if isinstance(getattr(config, setting), str):
settings = \
settings + '{} = "{}"\n'.format(
setting, getattr(config, setting))
else:
settings = \
settings + '{} = {}\n'.format(
setting, getattr(config, setting))
info['settings'] = settings
return make_json_response(
data=info,

View File

@ -101,32 +101,37 @@ export default function AboutComponent() {
<InputLabel>{aboutData.browser_details}</InputLabel>
</Grid>
</Grid>
<Grid container spacing={0} style={{marginBottom: '8px'}}>
<Grid item lg={3} md={3} sm={3} xs={12}>
<InputLabel style={{fontWeight: 'bold'}}>{gettext('Operating System')}</InputLabel>
{ aboutData.os_details &&
<Grid container spacing={0} style={{marginBottom: '8px'}}>
<Grid item lg={3} md={3} sm={3} xs={12}>
<InputLabel style={{fontWeight: 'bold'}}>{gettext('Operating System')}</InputLabel>
</Grid>
<Grid item lg={9} md={9} sm={9} xs={12}>
<InputLabel>{aboutData.os_details}</InputLabel>
</Grid>
</Grid>
<Grid item lg={9} md={9} sm={9} xs={12}>
<InputLabel>{aboutData.os_details}</InputLabel>
}
{ aboutData.config_db &&
<Grid container spacing={0} style={{marginBottom: '8px'}}>
<Grid item lg={3} md={3} sm={3} xs={12}>
<InputLabel style={{fontWeight: 'bold'}}>{gettext('pgAdmin Database File')}</InputLabel>
</Grid>
<Grid item lg={9} md={9} sm={9} xs={12}>
<InputLabel>{aboutData.config_db}</InputLabel>
</Grid>
</Grid>
</Grid>
<Grid container spacing={0} style={{marginBottom: '8px'}}>
<Grid item lg={3} md={3} sm={3} xs={12}>
<InputLabel style={{fontWeight: 'bold'}}>{gettext('pgAdmin Database File')}</InputLabel>
}
{ aboutData.log_file &&
<Grid container spacing={0} style={{marginBottom: '8px'}}>
<Grid item lg={3} md={3} sm={3} xs={12}>
<InputLabel style={{fontWeight: 'bold'}}>{gettext('Log File')}</InputLabel>
</Grid>
<Grid item lg={9} md={9} sm={9} xs={12}>
<InputLabel>{aboutData.log_file}</InputLabel>
</Grid>
</Grid>
<Grid item lg={9} md={9} sm={9} xs={12}>
<InputLabel>{aboutData.config_db}</InputLabel>
</Grid>
</Grid>
<Grid container spacing={0} style={{marginBottom: '8px'}}>
<Grid item lg={3} md={3} sm={3} xs={12}>
<InputLabel style={{fontWeight: 'bold'}}>{gettext('Log File')}</InputLabel>
</Grid>
<Grid item lg={9} md={9} sm={9} xs={12}>
<InputLabel>{aboutData.log_file}</InputLabel>
</Grid>
</Grid>
{ (aboutData.app_mode == 'Desktop' || (aboutData.app_mode == 'Server' && aboutData.admin)) &&
<>
}
{ aboutData.settings &&
<Box flexGrow="1" display="flex" flexDirection="column">
<Box>
<span style={{fontWeight: 'bold'}}>{gettext('Server Configuration')}</span>
@ -141,7 +146,6 @@ export default function AboutComponent() {
value={aboutData.settings}/>
</Box>
</Box>
</>
}
</Box>
);