1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-13 13:17:54 +03:00

added password encription for UDS

This commit is contained in:
Adolfo Gómez García 2020-03-30 18:11:02 +02:00
parent aaa2ce825e
commit 5e971db73f
4 changed files with 10 additions and 4 deletions

View File

@ -136,7 +136,7 @@ class CryptoManager:
logger.exception('Decripting: %s', value)
# logger.error(inspect.stack())
return 'decript error'
logger.debug('Decripted: %s %s', data, decrypted)
return decrypted.decode()
def AESCrypt(self, text: bytes, key: bytes, base64: bool = False) -> bytes:

View File

@ -41,6 +41,7 @@ import copy
from django.utils.translation import get_language, ugettext as _, ugettext_noop
from uds.core.util import encoders
from uds.core.managers import cryptoManager
logger = logging.getLogger(__name__)
@ -940,6 +941,8 @@ class UserInterface(metaclass=UserInterfaceType):
if v.isType(gui.InputField.EDITABLE_LIST) or v.isType(gui.InputField.MULTI_CHOICE_TYPE):
# logger.debug('Serializing value {0}'.format(v.value))
val = b'\001' + pickle.dumps(v.value, protocol=0)
if v.isType(gui.InfoField.PASSWORD_TYPE):
val = b'\004' + cryptoManager().encrypt(v.value.encode('utf8')).encode()
elif v.isType(gui.InputField.NUMERIC_TYPE):
val = str(int(v.num())).encode('utf8')
elif v.isType(gui.InputField.CHECKBOX_TYPE):
@ -984,13 +987,15 @@ class UserInterface(metaclass=UserInterfaceType):
try:
if v[0] == 1:
val = pickle.loads(v[1:])
elif v[0] == 4:
val = cryptoManager().decrypt(v[1:])
else:
val = v
# Ensure "legacy bytes" values are loaded correctly as unicode
if isinstance(val, bytes):
val = val.decode('utf_8')
except Exception:
# logger.exception('Pickling')
logger.exception('Pickling')
val = ''
self._gui[k].value = val
# logger.debug('Value for {0}:{1}'.format(k, val))

View File

@ -84,7 +84,8 @@ def connection(username: str, passwd: typing.Union[str, bytes], host: str, port:
l = ldap.initialize(uri=uri)
l.set_option(ldap.OPT_REFERRALS, 0)
l.network_timeout = l.timeout = int(timeout)
l.set_option(ldap.OPT_TIMEOUT, int(timeout))
l.network_timeout = int(timeout)
l.protocol_version = ldap.VERSION3
l.simple_bind_s(who=username, cred=password)

View File

@ -75,7 +75,7 @@ urlpatterns = [
# Federated authentication
re_path(r'^uds/page/auth/(?P<authName>[^/]+)$', uds.web.views.authCallback, name='page.auth.callback'),
re_path(r'^uds/page/auth/info/(?P<authName>[a-zA-Z0-9-])$', uds.web.views.authInfo, name='page.auth.info'),
re_path(r'^uds/page/auth/info/(?P<authName>[a-zA-Z0-9-]+)$', uds.web.views.authInfo, name='page.auth.info'),
# Ticket authentication related
re_path(r'^uds/page/ticket/auth/(?P<ticketId>[a-zA-Z0-9-])$', uds.web.views.ticketAuth, name='page.ticket.auth'),