forked from shaba/openuds
Adding console login/logout logic on static machines
This commit is contained in:
parent
47df6c58fc
commit
660cfdcd0e
@ -447,7 +447,7 @@ class CommonService: # pylint: disable=too-many-instance-attributes
|
||||
def logout(self, username: str) -> None:
|
||||
self._loggedIn = False
|
||||
|
||||
master_token = self._cfg.master_token if self.isManaged() else None
|
||||
master_token = self._cfg.master_token
|
||||
|
||||
# Own token will not be set if UDS did not assigned the initialized VM to an user
|
||||
# In that case, take master token (if machine is Unamanaged version)
|
||||
|
@ -448,7 +448,9 @@ class LoginLogout(ActorV3Action):
|
||||
service: 'services.Service' = Service.objects.get(
|
||||
token=self._params['token']
|
||||
).getInstance()
|
||||
# Locate an userService that belongs to this service and which
|
||||
|
||||
# We have a valid service, now we can make notifications
|
||||
|
||||
# Build the possible ids and make initial filter to match service
|
||||
idsList = [x['ip'] for x in self._params['id']] + [
|
||||
x['mac'] for x in self._params['id']
|
||||
@ -460,18 +462,11 @@ class LoginLogout(ActorV3Action):
|
||||
if not validId:
|
||||
raise Exception()
|
||||
|
||||
# Check secret if is stored
|
||||
storedInfo: typing.Optional[
|
||||
typing.MutableMapping[str, typing.Any]
|
||||
] = service.recoverIdInfo(validId)
|
||||
# If no secret valid
|
||||
if not storedInfo or self._params['secret'] != storedInfo['secret']:
|
||||
raise Exception()
|
||||
|
||||
# Notify Service that someone logged in/out
|
||||
if login:
|
||||
# Try to guess if this is a remote session
|
||||
is_remote = self._params.get('session_type', '')[:3] in ('xrdp', 'RDP-')
|
||||
is_remote = self._params.get('session_type', '')[:4] in ('xrdp', 'RDP-')
|
||||
service.processLogin(validId, remote_login=is_remote)
|
||||
else:
|
||||
service.processLogout(validId)
|
||||
|
@ -324,3 +324,12 @@ class IPMachinesService(IPServiceBase):
|
||||
return userServiceInstance.assign(theIP)
|
||||
|
||||
return userServiceInstance.error('IP already assigned')
|
||||
|
||||
def processLogin(self, id: str, remote_login: bool) -> None:
|
||||
logger.info('Processing login for %s', id)
|
||||
|
||||
def processLogout(self, id: str) -> None:
|
||||
logger.info('Processing logout for %s', id)
|
||||
|
||||
def getValidId(self, idsList: typing.Iterable[str]) -> typing.Optional[str]:
|
||||
return '192.168.15.13'
|
||||
|
Loading…
Reference in New Issue
Block a user