* added os type verify to ticketing auth

* fixed getType method
This commit is contained in:
Adolfo Gómez García 2020-03-06 10:54:54 +01:00
parent 099a9ba3c1
commit 3e67852d8a
3 changed files with 9 additions and 4 deletions

View File

@ -567,7 +567,8 @@ class UserServiceManager:
if not idTransport: # Find a suitable transport
t: Transport
for t in userService.deployed_service.transports.order_by('priority'):
if t.validForIp(srcIp):
typeTrans = t.getType()
if t.validForIp(srcIp) and typeTrans.supportsOs(os['OS']) and t.validForOs(os['OS']):
idTransport = t.uuid
break

View File

@ -80,7 +80,10 @@ class Transport(ManagedObjectModel, TaggingMixin):
:note: We only need to get info from this, not access specific data (class specific info)
"""
return transports.factory().lookup(self.data_type)
v = transports.factory().lookup(self.data_type)
if not v:
raise Exception('transport not found')
return v
def validForIp(self, ipStr: str) -> bool:
"""

View File

@ -196,9 +196,10 @@ def ticketAuth(request: 'HttpRequest', ticketId: str) -> HttpResponse: # pylint
request.user = usr # Temporarily store this user as "authenticated" user, next requests will be done using session
request.session['ticket'] = '1' # Store that user access is done using ticket
# Override and recalc transport based on current os
transport = None
logger.debug("Service & transport: %s, %s", servicePool, transport)
for v in ServicePool.objects.all():
logger.debug("%s %s", v.uuid, v.name)
# Check if servicePool is part of the ticket
if servicePool: