1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-08 21:18:00 +03:00

Some minor fixes ond Alexander code (some changes done on core after his contribution that has to be reflected, nothing important)

This commit is contained in:
Adolfo Gómez García 2023-05-17 18:25:25 +02:00
parent 98f79f83f1
commit 57d7b442f6
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
4 changed files with 61 additions and 72 deletions

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2023 Virtual Cable S.L.
# Copyright (c) 2012-2023 Virtual Cable S.L.U.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
@ -12,7 +12,7 @@
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# * Neither the name of Virtual Cable S.L.U. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
@ -38,12 +38,14 @@ from django.utils.translation import gettext_noop as _, gettext_lazy
from uds.core.ui import gui
from uds.core import exceptions
from uds.core.managers import cryptoManager
from uds.core.managers.crypto import CryptoManager
from .linux_osmanager import LinuxOsManager
if typing.TYPE_CHECKING:
from uds.models.user_service import UserService
from uds.core.environment import Environment
from uds.core.module import Module
logger = logging.getLogger(__name__)
@ -59,9 +61,7 @@ class LinuxOsADManager(LinuxOsManager):
length=64,
label=_('Domain'),
order=1,
tooltip=_(
'Domain to join machines to (use FQDN form, Netbios name not supported for most operations)'
),
tooltip=_('Domain to join machines to (use FQDN form, Netbios name not supported for most operations)'),
required=True,
)
account = gui.TextField(
@ -95,7 +95,7 @@ class LinuxOsADManager(LinuxOsManager):
{'id': 'sssd', 'text': gettext_lazy('SSSD')},
{'id': 'winbind', 'text': gettext_lazy('Winbind')},
],
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue='automatically',
)
membershipSoftware = gui.ChoiceField(
@ -107,7 +107,7 @@ class LinuxOsADManager(LinuxOsManager):
{'id': 'samba', 'text': gettext_lazy('Samba')},
{'id': 'adcli', 'text': gettext_lazy('adcli')},
],
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue='automatically',
)
removeOnExit = gui.CheckBoxField(
@ -116,21 +116,21 @@ class LinuxOsADManager(LinuxOsManager):
tooltip=_(
'If checked, UDS will try to remove the machine from the domain USING the provided credentials'
),
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue=gui.TRUE,
)
ssl = gui.CheckBoxField(
label=_('Use SSL'),
order=8,
tooltip=_('If checked, a ssl connection to Active Directory will be used'),
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue=gui.TRUE,
)
automaticIdMapping = gui.CheckBoxField(
label=_('Automatic ID mapping'),
order=9,
tooltip=_('If checked, automatic ID mapping'),
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue=gui.TRUE,
)
@ -150,19 +150,15 @@ class LinuxOsADManager(LinuxOsManager):
_serverSoftware: str
_membershipSoftware: str
def __init__(self, environment, values):
super(LinuxOsADManager, self).__init__(environment, values)
def __init__(self, environment: 'Environment', values: 'Module.ValuesType') -> None:
super().__init__(environment, values)
if values:
if values['domain'] == '':
raise exceptions.ValidationError(_('Must provide a domain!'))
if values['account'] == '':
raise exceptions.ValidationError(
_('Must provide an account to add machines to domain!')
)
raise exceptions.ValidationError(_('Must provide an account to add machines to domain!'))
if values['password'] == '':
raise exceptions.ValidationError(
_('Must provide a password for the account!')
)
raise exceptions.ValidationError(_('Must provide a password for the account!'))
self._domain = values['domain']
self._account = values['account']
self._password = values['password']
@ -185,9 +181,7 @@ class LinuxOsADManager(LinuxOsManager):
self._ssl = 'n'
self._automaticIdMapping = 'n'
def actorData(
self, userService: 'UserService'
) -> typing.MutableMapping[str, typing.Any]:
def actorData(self, userService: 'UserService') -> typing.MutableMapping[str, typing.Any]:
return {
'action': 'rename_ad',
'name': userService.getName(),
@ -213,7 +207,7 @@ class LinuxOsADManager(LinuxOsManager):
'v1',
self._domain,
self._account,
cryptoManager().encrypt(self._password),
CryptoManager().encrypt(self._password),
self._ou,
self._clientSoftware,
self._serverSoftware,
@ -230,7 +224,7 @@ class LinuxOsADManager(LinuxOsManager):
if values[0] in ('v1'):
self._domain = values[1]
self._account = values[2]
self._password = cryptoManager().decrypt(values[3])
self._password = CryptoManager().decrypt(values[3])
self._ou = values[4]
self._clientSoftware = values[5]
self._serverSoftware = values[6]
@ -252,4 +246,4 @@ class LinuxOsADManager(LinuxOsManager):
dct['removeOnExit'] = self._removeOnExit == 'y'
dct['ssl'] = self._ssl == 'y'
dct['automaticIdMapping'] = self._automaticIdMapping == 'y'
return dct
return dct

View File

@ -38,12 +38,14 @@ from django.utils.translation import gettext_noop as _, gettext_lazy
from uds.core.ui import gui
from uds.core import exceptions
from uds.core.managers import cryptoManager
from uds.core.managers.crypto import CryptoManager
from .linux_osmanager import LinuxOsManager
if typing.TYPE_CHECKING:
from uds.models.user_service import UserService
from uds.core.environment import Environment
from uds.core.module import Module
logger = logging.getLogger(__name__)
@ -59,9 +61,7 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
length=64,
label=_('Domain'),
order=1,
tooltip=_(
'Domain to join machines to (use FQDN form, Netbios name not supported for most operations)'
),
tooltip=_('Domain to join machines to (use FQDN form, Netbios name not supported for most operations)'),
required=True,
)
account = gui.TextField(
@ -87,7 +87,7 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
{'id': 'sssd', 'text': gettext_lazy('SSSD')},
{'id': 'winbind', 'text': gettext_lazy('Winbind')},
],
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue='automatically',
)
membershipSoftware = gui.ChoiceField(
@ -99,7 +99,7 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
{'id': 'samba', 'text': gettext_lazy('Samba')},
{'id': 'adcli', 'text': gettext_lazy('adcli')},
],
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue='automatically',
)
removeOnExit = gui.CheckBoxField(
@ -108,21 +108,21 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
tooltip=_(
'If checked, UDS will try to remove the machine from the domain USING the provided credentials'
),
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue=gui.TRUE,
)
ssl = gui.CheckBoxField(
label=_('Use SSL'),
order=7,
tooltip=_('If checked, a ssl connection to Active Directory will be used'),
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue=gui.TRUE,
)
automaticIdMapping = gui.CheckBoxField(
label=_('Automatic ID mapping'),
order=8,
tooltip=_('If checked, automatic ID mapping'),
tab=_('Advanced'),
tab=gui.Tab.ADVANCED,
defvalue=gui.TRUE,
)
@ -141,19 +141,15 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
_serverSoftware: str
_membershipSoftware: str
def __init__(self, environment, values):
super(LinuxOsFreeIPAManager, self).__init__(environment, values)
def __init__(self, environment: 'Environment', values: 'Module.ValuesType') -> None:
super().__init__(environment, values)
if values:
if values['domain'] == '':
raise exceptions.ValidationError(_('Must provide a domain!'))
if values['account'] == '':
raise exceptions.ValidationError(
_('Must provide an account to add machines to domain!')
)
raise exceptions.ValidationError(_('Must provide an account to add machines to domain!'))
if values['password'] == '':
raise exceptions.ValidationError(
_('Must provide a password for the account!')
)
raise exceptions.ValidationError(_('Must provide a password for the account!'))
self._domain = values['domain']
self._account = values['account']
self._password = values['password']
@ -174,9 +170,7 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
self._ssl = 'n'
self._automaticIdMapping = 'n'
def actorData(
self, userService: 'UserService'
) -> typing.MutableMapping[str, typing.Any]:
def actorData(self, userService: 'UserService') -> typing.MutableMapping[str, typing.Any]:
return {
'action': 'rename_ad',
'name': userService.getName(),
@ -201,7 +195,7 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
'v1',
self._domain,
self._account,
cryptoManager().encrypt(self._password),
CryptoManager().encrypt(self._password),
self._clientSoftware,
self._serverSoftware,
self._membershipSoftware,
@ -217,7 +211,7 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
if values[0] in ('v1'):
self._domain = values[1]
self._account = values[2]
self._password = cryptoManager().decrypt(values[3])
self._password = CryptoManager().decrypt(values[3])
self._clientSoftware = values[4]
self._serverSoftware = values[5]
self._membershipSoftware = values[6]
@ -237,4 +231,4 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
dct['removeOnExit'] = self._removeOnExit == 'y'
dct['ssl'] = self._ssl == 'y'
dct['automaticIdMapping'] = self._automaticIdMapping == 'y'
return dct
return dct

View File

@ -44,6 +44,7 @@ from uds.core.util import log
if typing.TYPE_CHECKING:
from uds.models.user_service import UserService
from uds.core.environment import Environment
from uds.core.module import Module
logger = logging.getLogger(__name__)
@ -97,7 +98,7 @@ class LinuxOsManager(osmanagers.OSManager):
def __setProcessUnusedMachines(self) -> None:
self.processUnusedMachines = self._onLogout == 'remove'
def __init__(self, environment, values) -> None:
def __init__(self, environment: 'Environment', values: 'Module.ValuesType') -> None:
super().__init__(environment, values)
if values is not None:
self._onLogout = values['onLogout']

View File

@ -88,29 +88,29 @@ class HTML5SSHTransport(transports.Transport):
tooltip=_('Username for SSH connection authentication.'),
tab=gui.Tab.CREDENTIALS,
)
password = gui.PasswordField(
label=_('Password'),
order=21,
tooltip=_('Password for SSH connection authentication'),
tab=gui.Tab.CREDENTIALS,
)
sshPrivateKey = gui.TextField(
label=_('SSH Private Key'),
order=22,
multiline=4,
tooltip=_(
'Private key for SSH authentication. If not provided, password authentication is used.'
),
tab=gui.Tab.CREDENTIALS,
)
sshPassphrase = gui.PasswordField(
label=_('SSH Private Key Passphrase'),
order=23,
tooltip=_(
'Passphrase for SSH private key if it is required. If not provided, but it is needed, user will be prompted for it.'
),
tab=gui.Tab.CREDENTIALS,
)
# password = gui.PasswordField(
# label=_('Password'),
# order=21,
# tooltip=_('Password for SSH connection authentication'),
# tab=gui.Tab.CREDENTIALS,
# )
# sshPrivateKey = gui.TextField(
# label=_('SSH Private Key'),
# order=22,
# multiline=4,
# tooltip=_(
# 'Private key for SSH authentication. If not provided, password authentication is used.'
# ),
# tab=gui.Tab.CREDENTIALS,
# )
# sshPassphrase = gui.PasswordField(
# label=_('SSH Private Key Passphrase'),
# order=23,
# tooltip=_(
# 'Passphrase for SSH private key if it is required. If not provided, but it is needed, user will be prompted for it.'
# ),
# tab=gui.Tab.CREDENTIALS,
# )
sshCommand = gui.TextField(
label=_('SSH Command'),