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 = {} info = {}
# Get OS , NW.js, Browser details # Get OS , NW.js, Browser details
browser, os_details, nwjs_version = detect_browser(request) browser, os_details, nwjs_version = detect_browser(request)
admin = is_admin(current_user.email)
if nwjs_version: if nwjs_version:
info['nwjs'] = 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: if config.SERVER_MODE:
info['app_mode'] = gettext('Server') info['app_mode'] = gettext('Server')
admin = is_admin(current_user.email)
info['admin'] = admin
else: else:
info['app_mode'] = gettext('Desktop') info['app_mode'] = gettext('Desktop')
info['browser_details'] = browser
info['version'] = config.APP_VERSION
info['admin'] = admin
info['current_user'] = current_user.email info['current_user'] = current_user.email
settings = "" if admin:
for setting in dir(config): settings = ""
if not setting.startswith('_') and setting.isupper() and \ info['os_details'] = os_details
setting not in ['CSRF_SESSION_KEY', info['log_file'] = config.LOG_FILE
'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 # 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( return make_json_response(
data=info, data=info,

View File

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