Added a couple of fixes for ticket authentication

This commit is contained in:
Adolfo Gómez García 2015-11-06 04:08:10 +01:00
parent b56dbcfdfd
commit 0eab8d0f3f
3 changed files with 9 additions and 7 deletions

View File

@ -51,7 +51,7 @@ import requests
import json import json
import logging import logging
__updated__ = '2015-11-05' __updated__ = '2015-11-06'
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -556,7 +556,7 @@ class UserServiceManager(object):
logger.debug('Found service: {0}'.format(userService)) 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'): for v in userService.deployed_service.transports.order_by('priority'):
if v.validForIp(srcIp): if v.validForIp(srcIp):
idTransport = v.uuid idTransport = v.uuid
@ -604,4 +604,4 @@ class UserServiceManager(object):
else: else:
log.doLog(userService, log.WARN, "User {0} from {1} tried to access, but service was not ready".format(user.name, srcIp), log.WEB) 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)

View File

@ -32,7 +32,7 @@
''' '''
from __future__ import unicode_literals from __future__ import unicode_literals
__updated__ = '2015-04-30' __updated__ = '2015-11-06'
class ServiceException(Exception): class ServiceException(Exception):
@ -104,3 +104,5 @@ class ServiceNotReadyError(ServiceException):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ServiceNotReadyError, self).__init__(*args, **kwargs) super(ServiceNotReadyError, self).__init__(*args, **kwargs)
self.code = kwargs.get('code', 0x0000) self.code = kwargs.get('code', 0x0000)
self.service = kwargs.get('service', None)
self.transport = kwargs.get('transport', None)

View File

@ -58,7 +58,7 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
__updated__ = '2015-09-12' __updated__ = '2015-11-06'
@csrf_exempt @csrf_exempt
@ -194,11 +194,11 @@ def ticketAuth(request, ticketId):
# Check if servicePool is part of the ticket # Check if servicePool is part of the ticket
if servicePool is not None: if servicePool is not None:
# If service pool is in there, also is transport # 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 ip, userService, userServiceInstance, transport, transportInstance = res
if transportInstance.ownLink is True: if transportInstance.ownLink is True:
link = reverse('TransportOwnLink', args=('A' + userServiceInstance.uuid, transportInstance.uuid)) link = reverse('TransportOwnLink', args=('A' + userService.uuid, transport.uuid))
else: else:
link = html.udsAccessLink(request, 'A' + userService.uuid, transport.uuid) link = html.udsAccessLink(request, 'A' + userService.uuid, transport.uuid)