Merge remote-tracking branch 'origin/v3.5'

This commit is contained in:
Adolfo Gómez García 2021-12-20 12:12:28 +01:00
commit 354061f55c

View File

@ -351,54 +351,64 @@ class HTML5RDPTransport(transports.Transport):
def processedUser( def processedUser(
self, userService: 'models.UserService', user: 'models.User' self, userService: 'models.UserService', user: 'models.User'
) -> str: ) -> str:
v = self.processUserAndPassword(userService, user, '') v = self.getConnectionInfo(userService, user, '')
return v['username'] return v['username']
def processUserAndPassword(
self, userService: 'models.UserService', user: 'models.User', password: str
) -> typing.Dict[str, str]:
username: str = user.getUsernameForAuth()
if self.fixedName.value != '': def getConnectionInfo(
username = self.fixedName.value self,
userService: typing.Union['models.UserService', 'models.ServicePool'],
user: 'models.User',
password: str,
) -> typing.Mapping[str, str]:
host: str = ''
username: str = ''
passwd: str = ''
# Maybe this is called from another provider, as for example WYSE, that need all connections BEFORE
if isinstance(userService, models.UserService):
conDatta = userService.getInstance().getConnectionData() # type: ignore # available only for RDS services
if not conDatta:
raise Exception('Invalid connection data received!')
host, username, passwd = conDatta
# if no password is provided from service, use "user" one
if passwd is None:
passwd = password
if username is None:
username = user.getUsernameForAuth()
proc = username.split('@') proc = username.split('@')
domain = proc[1] if len(proc) > 1 else '' if len(proc) > 1:
domain = proc[1]
else:
domain = ''
username = proc[0] username = proc[0]
if self.fixedPassword.value != '':
password = self.fixedPassword.value
azureAd = False
if self.fixedDomain.value != '': if self.fixedDomain.value != '':
if self.fixedDomain.value.lower() == 'azuread': domain = self.fixedDomain.value
azureAd = True
else:
domain = self.fixedDomain.value
if self.useEmptyCreds.isTrue(): if self.useEmptyCreds.isTrue():
username, password, domain = '', '', '' username, passwd, domain = '', '', ''
# If no domain to be transfered, set it to ''
if self.withoutDomain.isTrue(): if self.withoutDomain.isTrue():
domain = '' domain = ''
if '.' in domain: # Dotter domain form if '.' in domain: # FQDN domain form
username = username + '@' + domain username = username + '@' + domain
domain = '' domain = ''
# If AzureAD, include it on username
if azureAd:
username = 'AzureAD\\' + username
# Fix username/password acording to os manager # Fix username/password acording to os manager
username, password = userService.processUserPassword(username, password) username, passwd = userService.processUserPassword(username, passwd)
return { return {
'protocol': self.protocol, 'protocol': self.protocol,
'username': username, 'username': username,
'password': password, 'password': passwd,
'domain': domain, 'domain': domain,
'host': host,
} }
def getLink( # pylint: disable=too-many-locals def getLink( # pylint: disable=too-many-locals
@ -411,7 +421,7 @@ class HTML5RDPTransport(transports.Transport):
password: str, password: str,
request: 'HttpRequest', request: 'HttpRequest',
) -> str: ) -> str:
credsInfo = self.processUserAndPassword(userService, user, password) credsInfo = self.getConnectionInfo(userService, user, password)
username, password, domain = ( username, password, domain = (
credsInfo['username'], credsInfo['username'],
credsInfo['password'], credsInfo['password'],