mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
* Several fixes to UDS Actor (minor ones)
* Minor adaptions to allow REST actor to connect with "tickets' * Fix to TicketStore
This commit is contained in:
parent
ccebca9748
commit
1733f142be
@ -241,7 +241,7 @@ class UDSSystemTray(QtGui.QSystemTrayIcon):
|
||||
|
||||
def logoff(self):
|
||||
self.counter += 1
|
||||
print("Loggof --", self.counter)
|
||||
# print("Logofff --", self.counter)
|
||||
|
||||
def information(self, info):
|
||||
'''
|
||||
|
@ -183,9 +183,13 @@ class Api(object):
|
||||
res = self._request(url)['result']
|
||||
logger.debug('Got response parameters: {}'.format(res))
|
||||
self.uuid, self.mac = res[0:2]
|
||||
self.idle = int(res[2])
|
||||
if self.idle < 30:
|
||||
self.idle = None # No values under 30 seconds are allowed :)
|
||||
# Optional idle parameter
|
||||
try:
|
||||
self.idle = int(res[2])
|
||||
if self.idle < 30:
|
||||
self.idle = None # No values under 30 seconds are allowed :)
|
||||
except Exception:
|
||||
self.idle = None
|
||||
|
||||
return self.uuid
|
||||
|
||||
|
@ -80,7 +80,7 @@ class Logger(object):
|
||||
self.log(WARN, message)
|
||||
|
||||
def info(self, message):
|
||||
self.log(WARN, message)
|
||||
self.log(INFO, message)
|
||||
|
||||
def error(self, message):
|
||||
self.log(ERROR, message)
|
||||
|
@ -83,12 +83,13 @@ def readConfig():
|
||||
return None
|
||||
|
||||
|
||||
def writeConfig(data):
|
||||
def writeConfig(data, fixPermissions=True):
|
||||
try:
|
||||
key = wreg.OpenKey(baseKey, path, 0, wreg.KEY_ALL_ACCESS) # @UndefinedVariable
|
||||
except Exception:
|
||||
key = wreg.CreateKeyEx(baseKey, path, 0, wreg.KEY_ALL_ACCESS) # @UndefinedVariable
|
||||
fixRegistryPermissions(key.handle)
|
||||
if fixPermissions is True:
|
||||
fixRegistryPermissions(key.handle)
|
||||
|
||||
wreg.SetValueEx(key, "", 0, wreg.REG_BINARY, encoder(cPickle.dumps(data))) # @UndefinedVariable
|
||||
wreg.CloseKey(key) # @UndefinedVariable
|
||||
|
@ -39,6 +39,7 @@ from uds.core.util.State import State
|
||||
from uds.core.util.model import processUuid
|
||||
from uds.core.util import log
|
||||
from uds.core.managers import cryptoManager
|
||||
from uds.models import TicketStore
|
||||
from uds.REST import Handler
|
||||
from uds.REST import RequestError
|
||||
from uds.models import UserService
|
||||
@ -120,6 +121,21 @@ class Actor(Handler):
|
||||
|
||||
return services[0]
|
||||
|
||||
def getTicket(self):
|
||||
'''
|
||||
Processes get requests in order to obtain a ticket content
|
||||
GET /rest/ticket/[ticketId]
|
||||
'''
|
||||
logger.debug("Ticket args for GET: {0}".format(self._args))
|
||||
|
||||
if len(self._args) != 2:
|
||||
raise RequestError('Invalid request')
|
||||
|
||||
try:
|
||||
return Actor.result(TicketStore.get(self._args[1], invalidate=False)) # TODO: Remove False after development
|
||||
except Exception:
|
||||
return Actor.result({})
|
||||
|
||||
def get(self):
|
||||
'''
|
||||
Processes get requests
|
||||
@ -129,6 +145,12 @@ class Actor(Handler):
|
||||
if len(self._args) < 1:
|
||||
raise RequestError('Invalid request')
|
||||
|
||||
if self._args[0] == 'ticket':
|
||||
return self.getTicket()
|
||||
|
||||
if self._args[0] == 'testn': # Test, but without master key
|
||||
return self.test()
|
||||
|
||||
# if path is .../test (/rest/actor/[test|init]?key=.....&version=....&id=....) version & ids are only used on init
|
||||
if self._args[0] in ('test', 'init'):
|
||||
v = self.validateRequestKey()
|
||||
|
@ -199,6 +199,9 @@ class Connection(Handler):
|
||||
if len(self._args) == 0:
|
||||
# Return list of services/transports
|
||||
return self.serviceList()
|
||||
if len(self._args) == 1:
|
||||
# Maybe we are requesting a ticket content?
|
||||
return self.getTicketContent()
|
||||
|
||||
if len(self._args) == 2:
|
||||
# Return connection & validate access for service/transport
|
||||
|
@ -93,9 +93,9 @@ def getOsFromUA(ua):
|
||||
Basic OS Client detector (very basic indeed :-))
|
||||
'''
|
||||
if ua is None:
|
||||
os = DEFAULT_OS
|
||||
else:
|
||||
os = 'Unknown'
|
||||
ua = 'Unknown'
|
||||
|
||||
os = 'Unknown'
|
||||
|
||||
res = DictAsObj({'OS': os, 'Version': '0.0', 'Browser': 'unknown'})
|
||||
for os in knownOss:
|
||||
@ -106,26 +106,30 @@ def getOsFromUA(ua):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
match = None
|
||||
|
||||
for ruleKey, ruleValue in browserRules.iteritems():
|
||||
must, mustNot = ruleValue
|
||||
|
||||
for mustRe in browsersREs[must]:
|
||||
match = mustRe.search(ua)
|
||||
if match is not None:
|
||||
# Check against no machin rules
|
||||
for mustNotREs in mustNot:
|
||||
for cre in browsersREs[mustNotREs]:
|
||||
if cre.search(ua) is not None:
|
||||
match = None
|
||||
break
|
||||
if match is None:
|
||||
if match is None:
|
||||
continue
|
||||
# Check against no machin rules
|
||||
for mustNotREs in mustNot:
|
||||
for cre in browsersREs[mustNotREs]:
|
||||
if cre.search(ua) is not None:
|
||||
match = None
|
||||
break
|
||||
if match is None:
|
||||
break
|
||||
if match is not None:
|
||||
break
|
||||
if match is not None:
|
||||
break
|
||||
|
||||
if match is not None:
|
||||
res.Browser = ruleKey
|
||||
res.Browser = ruleKey # pylint: disable=undefined-loop-variable
|
||||
res.Version = match.groups(1)[0]
|
||||
|
||||
return res
|
||||
|
@ -44,7 +44,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2015-04-27'
|
||||
__updated__ = '2015-05-25'
|
||||
|
||||
|
||||
class TicketStore(UUIDModel):
|
||||
@ -78,7 +78,7 @@ class TicketStore(UUIDModel):
|
||||
@staticmethod
|
||||
def generateUuid():
|
||||
# more secure is this:
|
||||
# ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(40))
|
||||
# ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(40))
|
||||
return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(40))
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user