forked from shaba/openuds
Fixed OSManager to allow:
1.- Posting "POST"-only messages through "GET" method. (Only basic messages) 2.- Allow notify login/logout for user services without os manager
This commit is contained in:
parent
786945fcbf
commit
13f97248f6
@ -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.core.osmanagers import OSManager
|
||||
from uds.models import TicketStore
|
||||
from uds.REST import Handler
|
||||
from uds.REST import RequestError
|
||||
@ -145,6 +146,10 @@ class Actor(Handler):
|
||||
if len(self._args) < 1:
|
||||
raise RequestError('Invalid request')
|
||||
|
||||
if self._args[0] == 'PostThoughGet':
|
||||
self._args = self._args[1:] # Remove first argument
|
||||
return self.post()
|
||||
|
||||
if self._args[0] == 'ticket':
|
||||
return self.getTicket()
|
||||
|
||||
@ -211,8 +216,20 @@ class Actor(Handler):
|
||||
logger.debug(self._params)
|
||||
data = '\t'.join((self._params.get('message'), six.text_type(self._params.get('level', 10000))))
|
||||
|
||||
osmanager = service.getInstance().osmanager()
|
||||
|
||||
try:
|
||||
res = service.getInstance().osmanager().process(service, message, data, options={'scramble': False})
|
||||
if osmanager is None:
|
||||
if message in ('login', 'logout'):
|
||||
osm = OSManager(None, None) # Dummy os manager, just for using "logging" capability
|
||||
if message == 'login':
|
||||
osm.loggedIn(service)
|
||||
else:
|
||||
osm.loggedOut(service)
|
||||
return 'ok'
|
||||
raise Exception('Unknown message {} for an user service without os manager'.format(message))
|
||||
else:
|
||||
res = osmanager.process(service, message, data, options={'scramble': False})
|
||||
except Exception as e:
|
||||
return Actor.result(six.text_type(e), ERR_OSMANAGER_ERROR)
|
||||
|
||||
|
@ -42,7 +42,7 @@ from uds.core import Module
|
||||
|
||||
import six
|
||||
|
||||
__updated__ = '2016-10-03'
|
||||
__updated__ = '2017-10-02'
|
||||
|
||||
STORAGE_KEY = 'osmk'
|
||||
|
||||
@ -204,6 +204,9 @@ class OSManager(Module):
|
||||
knownUserIP = userService.src_ip + ':' + userService.src_hostname
|
||||
knownUserIP = knownUserIP if knownUserIP != ':' else 'unknown'
|
||||
|
||||
if userName is None:
|
||||
userName = 'unknown'
|
||||
|
||||
addEvent(userService.deployed_service, ET_LOGIN, fld1=userName, fld2=knownUserIP, fld3=serviceIp, fld4=fullUserName)
|
||||
|
||||
log.doLog(userService, log.INFO, "User {0} has logged in".format(userName), log.OSMANAGER)
|
||||
@ -247,6 +250,9 @@ class OSManager(Module):
|
||||
knownUserIP = userService.src_ip + ':' + userService.src_hostname
|
||||
knownUserIP = knownUserIP if knownUserIP != ':' else 'unknown'
|
||||
|
||||
if userName is None:
|
||||
userName = 'unknown'
|
||||
|
||||
addEvent(userService.deployed_service, ET_LOGOUT, fld1=userName, fld2=knownUserIP, fld3=serviceIp, fld4=fullUserName)
|
||||
|
||||
log.doLog(userService, log.INFO, "User {0} has logged out".format(userName), log.OSMANAGER)
|
||||
|
@ -41,7 +41,7 @@ from uds.core.ui import gui
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2017-09-29'
|
||||
__updated__ = '2017-10-02'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -167,7 +167,8 @@ class OGService(Service):
|
||||
return self.parent().notifyEvents(machineId, self.getLoginNotifyURL(serviceUUID), self.getLogoutNotifyURL(serviceUUID))
|
||||
|
||||
def _notifyURL(self, uuid, message):
|
||||
return '{accessURL}rest/actor/{uuid}/{message}'.format(
|
||||
# The URL is "GET messages URL".
|
||||
return '{accessURL}rest/actor/PostThoughGet/{uuid}/{message}'.format(
|
||||
accessURL=self.parent().getUDSServerAccessUrl(),
|
||||
uuid=uuid,
|
||||
message=message
|
||||
|
@ -45,14 +45,14 @@ import six
|
||||
import requests
|
||||
import json
|
||||
|
||||
__updated__ = '2017-09-29'
|
||||
__updated__ = '2017-10-02'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# URLS
|
||||
|
||||
# Fake part
|
||||
FAKE = False
|
||||
FAKE = True
|
||||
CACHE_VALIDITY = 180
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user