From 0eab8d0f3fb421b2770772883f0a484c66daa65a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 6 Nov 2015 04:08:10 +0100 Subject: [PATCH] Added a couple of fixes for ticket authentication --- server/src/uds/core/managers/UserServiceManager.py | 6 +++--- server/src/uds/core/services/Exceptions.py | 4 +++- server/src/uds/web/views/auth.py | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/uds/core/managers/UserServiceManager.py b/server/src/uds/core/managers/UserServiceManager.py index 4cbd9b39..a18e2562 100644 --- a/server/src/uds/core/managers/UserServiceManager.py +++ b/server/src/uds/core/managers/UserServiceManager.py @@ -51,7 +51,7 @@ import requests import json import logging -__updated__ = '2015-11-05' +__updated__ = '2015-11-06' logger = logging.getLogger(__name__) @@ -556,7 +556,7 @@ class UserServiceManager(object): logger.debug('Found service: {0}'.format(userService)) - if idTransport is None: # Find a suitable transport + if idTransport is None or idTransport == '': # Find a suitable transport for v in userService.deployed_service.transports.order_by('priority'): if v.validForIp(srcIp): idTransport = v.uuid @@ -604,4 +604,4 @@ class UserServiceManager(object): else: log.doLog(userService, log.WARN, "User {0} from {1} tried to access, but service was not ready".format(user.name, srcIp), log.WEB) - raise ServiceNotReadyError(code=serviceNotReadyCode) + raise ServiceNotReadyError(code=serviceNotReadyCode, service=userService, transport=trans) diff --git a/server/src/uds/core/services/Exceptions.py b/server/src/uds/core/services/Exceptions.py index cd497707..869c6a70 100644 --- a/server/src/uds/core/services/Exceptions.py +++ b/server/src/uds/core/services/Exceptions.py @@ -32,7 +32,7 @@ ''' from __future__ import unicode_literals -__updated__ = '2015-04-30' +__updated__ = '2015-11-06' class ServiceException(Exception): @@ -104,3 +104,5 @@ class ServiceNotReadyError(ServiceException): def __init__(self, *args, **kwargs): super(ServiceNotReadyError, self).__init__(*args, **kwargs) self.code = kwargs.get('code', 0x0000) + self.service = kwargs.get('service', None) + self.transport = kwargs.get('transport', None) diff --git a/server/src/uds/web/views/auth.py b/server/src/uds/web/views/auth.py index a20c0861..6121f75b 100644 --- a/server/src/uds/web/views/auth.py +++ b/server/src/uds/web/views/auth.py @@ -58,7 +58,7 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2015-09-12' +__updated__ = '2015-11-06' @csrf_exempt @@ -194,11 +194,11 @@ def ticketAuth(request, ticketId): # Check if servicePool is part of the ticket if servicePool is not None: # If service pool is in there, also is transport - res = userServiceManager().getService(request.user, request.ip, 'F' + servicePool, transport) + res = userServiceManager().getService(request.user, request.ip, 'F' + servicePool, transport, False) ip, userService, userServiceInstance, transport, transportInstance = res if transportInstance.ownLink is True: - link = reverse('TransportOwnLink', args=('A' + userServiceInstance.uuid, transportInstance.uuid)) + link = reverse('TransportOwnLink', args=('A' + userService.uuid, transport.uuid)) else: link = html.udsAccessLink(request, 'A' + userService.uuid, transport.uuid)