mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-23 17:34:17 +03:00
small guacamole dispatcher fix. Backported to 3.6
This commit is contained in:
parent
02877f9095
commit
8cafc6d797
@ -51,7 +51,9 @@ CONTENT_TYPE = 'text/plain'
|
||||
|
||||
|
||||
def dict2resp(dct: typing.Mapping[typing.Any, typing.Any]) -> str:
|
||||
return '\r'.join((str(k) + '\t' + str(v) for k, v in dct.items()))
|
||||
result = '\r'.join((str(k) + '\t' + str(v) for k, v in dct.items()))
|
||||
logger.debug('Guacamole response: %s', result.replace('\r', ',').replace('\t', '='))
|
||||
return result
|
||||
|
||||
|
||||
@auth.trustedSourceRequired
|
||||
@ -78,20 +80,26 @@ def guacamole(
|
||||
|
||||
try:
|
||||
userService = UserService.objects.get(uuid=ti['userService'])
|
||||
if not userService.isUsable() or not userService.user:
|
||||
# Not usable, or not assigned to a user, we will not use it
|
||||
if not userService.isUsable():
|
||||
raise Exception() # Not usable, so we will not use it :)
|
||||
user = userService.user
|
||||
# check service owner is the same as the one that requested the ticket
|
||||
if not user or user.uuid != ti['user']:
|
||||
logger.error(
|
||||
'The requested userservice has changed owner and is not accesible'
|
||||
)
|
||||
raise Exception()
|
||||
# Log message and event
|
||||
protocol = 'RDS' if 'remote-app' in val else val['protocol'].upper()
|
||||
host = val.get('hostname', '0.0.0.0')
|
||||
msg = f'User {userService.user.name} started HTML5 {protocol} tunnel to {host}.'
|
||||
log.doLog(userService.user.manager, log.INFO, msg)
|
||||
msg = f'User {user.name} started HTML5 {protocol} tunnel to {host}.'
|
||||
log.doLog(user.manager, log.INFO, msg)
|
||||
log.doLog(userService, log.INFO, msg)
|
||||
|
||||
events.addEvent(
|
||||
userService.deployed_service,
|
||||
events.ET_TUNNEL_OPEN,
|
||||
username=userService.user.pretty_name,
|
||||
username=user.pretty_name,
|
||||
source='HTML5-'
|
||||
+ protocol, # On HTML5, currently src is not provided by Guacamole
|
||||
dstip=host,
|
||||
@ -103,11 +111,6 @@ def guacamole(
|
||||
'The requested guacamole userservice does not exists anymore'
|
||||
)
|
||||
raise # Let it be handled by the upper layers
|
||||
if userService.user.uuid != ti['user']:
|
||||
logger.error(
|
||||
'The requested userservice has changed owner and is not accesible'
|
||||
)
|
||||
raise Exception() # Let it be handled by the upper layers
|
||||
|
||||
if 'password' in val:
|
||||
val['password'] = cryptoManager().symDecrpyt(val['password'], scrambler)
|
||||
|
Loading…
Reference in New Issue
Block a user