mirror of https://github.com/nicolargo/glances.git
Hide password in the Glances browser form #503
This commit is contained in:
parent
b8304d8796
commit
e7a3de5038
1
NEWS.rst
1
NEWS.rst
|
|
@ -48,6 +48,7 @@ Enhancements:
|
|||
* [WebUI] Added smart plugin support #2435
|
||||
* No more threshold display in the WebUI cpu/mem and memswap plugins #2420
|
||||
* Refactor Glances curses code #2580
|
||||
* Hide password in the Glances browser form #503
|
||||
* Replace Bottle by FastAPI #2181
|
||||
* Replace py3nvml with nvidia-ml-py #2688
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ class GlancesClientBrowser(object):
|
|||
# Else, the password should be enter by the user
|
||||
# Display a popup to enter password
|
||||
clear_password = self.screen.display_popup(
|
||||
'Password needed for {}: '.format(server['name']), is_input=True
|
||||
'Password needed for {}: '.format(server['name']),
|
||||
popup_type='input', is_password=True
|
||||
)
|
||||
# Store the password for the selected server
|
||||
if clear_password is not None:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
import getpass
|
||||
|
||||
from glances.globals import MACOS, WINDOWS, nativestr, u, itervalues, enable, disable
|
||||
from glances.logger import logger
|
||||
|
|
@ -920,7 +921,12 @@ class _GlancesCurses(object):
|
|||
self.display_plugin(stat_display[p])
|
||||
|
||||
def display_popup(
|
||||
self, message, size_x=None, size_y=None, duration=3, popup_type='info', input_size=30, input_value=None
|
||||
self, message,
|
||||
size_x=None, size_y=None,
|
||||
duration=3,
|
||||
popup_type='info',
|
||||
input_size=30, input_value=None,
|
||||
is_password=False
|
||||
):
|
||||
"""
|
||||
Display a centered popup.
|
||||
|
|
@ -978,6 +984,8 @@ class _GlancesCurses(object):
|
|||
self.wait(duration * 1000)
|
||||
return True
|
||||
elif popup_type == 'input':
|
||||
logger.info(popup_type)
|
||||
logger.info(is_password)
|
||||
# Create a sub-window for the text field
|
||||
sub_pop = popup.derwin(1, input_size, 2, 2 + len(m))
|
||||
sub_pop.attron(self.colors_list['FILTER'])
|
||||
|
|
@ -990,15 +998,20 @@ class _GlancesCurses(object):
|
|||
# Create the textbox inside the sub-windows
|
||||
self.set_cursor(2)
|
||||
self.term_window.keypad(1)
|
||||
if is_password:
|
||||
textbox = getpass.getpass('')
|
||||
self.set_cursor(0)
|
||||
if textbox != '':
|
||||
return textbox
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
textbox = GlancesTextbox(sub_pop, insert_mode=True)
|
||||
textbox.edit()
|
||||
self.set_cursor(0)
|
||||
# self.term_window.keypad(0)
|
||||
if textbox.gather() != '':
|
||||
logger.debug("User enters the following string: %s" % textbox.gather())
|
||||
return textbox.gather()[:-1]
|
||||
else:
|
||||
logger.debug("User enters an empty string")
|
||||
return None
|
||||
elif popup_type == 'yesno':
|
||||
# # Create a sub-window for the text field
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ class GlancesPassword(object):
|
|||
|
||||
Return the comparison with the encrypted_password.
|
||||
"""
|
||||
logger.info("Check password")
|
||||
salt, encrypted_password = hashed_password.split('$')
|
||||
re_encrypted_password = self.get_hash(plain_password, salt=salt)
|
||||
return encrypted_password == re_encrypted_password
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler, object):
|
|||
if username in self.server.user_dict:
|
||||
from glances.password import GlancesPassword
|
||||
|
||||
pwd = GlancesPassword(username=username, config=self.config)
|
||||
# TODO: config is not taken into account: it may be a problem ?
|
||||
pwd = GlancesPassword(username=username, config=None)
|
||||
return pwd.check_password(self.server.user_dict[username], password)
|
||||
else:
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in New Issue