1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-20 06:50:23 +03:00

Merge remote-tracking branch 'origin/v4.0'

This commit is contained in:
Adolfo Gómez García 2025-01-08 17:22:04 +01:00
commit 10fda01ad3
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
3 changed files with 23 additions and 12 deletions

View File

@ -78,7 +78,7 @@ class OAuth2Authenticator(auths.Authenticator):
required=True,
tab=_('Server'),
)
client_secret = gui.TextField(
client_secret = gui.PasswordField(
length=128,
label=_('Client Secret'),
order=3,

View File

@ -76,7 +76,7 @@ class RadiusAuth(auths.Authenticator):
tooltip=_('Radius authentication port (usually 1812)'),
required=True,
)
secret = gui.TextField(
secret = gui.PasswordField(
length=64,
label=_('Secret'),
order=3,

View File

@ -1645,14 +1645,17 @@ class UserInterface(metaclass=UserInterfaceType):
if internal_field_type not in FIELD_DECODERS:
logger.warning('Field %s has no decoder', field_name)
continue
if field_type != internal_field_type.name:
logger.warning(
'Field %s has different type than expected: %s != %s',
field_name,
field_type,
internal_field_type.name,
)
continue
# Especial case for text fields converted to password fields
if not (internal_field_type == types.ui.FieldType.PASSWORD and field_type == types.ui.FieldType.TEXT.name):
logger.warning(
'Field %s has different type than expected: %s != %s',
field_name,
field_type,
internal_field_type.name,
)
continue
self._gui[field_name].value = FIELD_DECODERS[internal_field_type](field_value)
return False
@ -1776,6 +1779,16 @@ class UserInterface(metaclass=UserInterfaceType):
return field_name in self._gui
def password_compat_field_decoder(value: str) -> str:
"""
Compatibility function to decode text fields converted to password fields
"""
try:
value = CryptoManager.manager().aes_decrypt(value.encode('utf8'), UDSK, True).decode()
except Exception:
pass
return value
# Dictionaries used to encode/decode fields to be stored on database
FIELDS_ENCODERS: typing.Final[
collections.abc.Mapping[
@ -1804,9 +1817,7 @@ FIELD_DECODERS: typing.Final[
types.ui.FieldType.TEXT: lambda x: x,
types.ui.FieldType.TEXT_AUTOCOMPLETE: lambda x: x,
types.ui.FieldType.NUMERIC: int,
types.ui.FieldType.PASSWORD: lambda x: (
CryptoManager.manager().aes_decrypt(x.encode(), UDSK, True).decode()
),
types.ui.FieldType.PASSWORD: password_compat_field_decoder,
types.ui.FieldType.HIDDEN: lambda x: x,
types.ui.FieldType.CHOICE: lambda x: x,
types.ui.FieldType.MULTICHOICE: lambda x: serializer.deserialize(base64.b64decode(x.encode())),