forked from shaba/openuds
Merge branch 'v3.0' of https://github.com/dkmstr/openuds into v3.0
This commit is contained in:
commit
620e8fee94
@ -319,26 +319,27 @@ def webLogout(request: HttpRequest, exit_url: typing.Optional[str] = None) -> Ht
|
||||
Helper function to clear user related data from session. If this method is not used, the session we be cleaned anyway
|
||||
by django in regular basis.
|
||||
"""
|
||||
if exit_url is None:
|
||||
exit_url = request.build_absolute_uri(reverse('page.logout'))
|
||||
# exit_url = GlobalConfig.LOGIN_URL.get()
|
||||
# if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
|
||||
# exit_url = exit_url.replace('http://', 'https://')
|
||||
|
||||
if request.user:
|
||||
authenticator = request.user.manager.getInstance()
|
||||
authenticator: 'auths.Authenticator' = request.user.manager.getInstance()
|
||||
username = request.user.name
|
||||
exit_url = authenticator.logout(username) or exit_url
|
||||
if request.user.id != ROOT_ID:
|
||||
# Try yo invoke logout of auth
|
||||
events.addEvent(request.user.manager, events.ET_LOGOUT, username=request.user.name, srcip=request.ip)
|
||||
else: # No user, redirect to /
|
||||
return HttpResponseRedirect(reverse('page.login'))
|
||||
|
||||
request.session.clear()
|
||||
if exit_url is None:
|
||||
exit_url = reverse('page.logout')
|
||||
# exit_url = GlobalConfig.LOGIN_URL.get()
|
||||
# if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
|
||||
# exit_url = exit_url.replace('http://', 'https://')
|
||||
else: # No user, redirect to logout page directly
|
||||
return HttpResponseRedirect(exit_url)
|
||||
|
||||
# Try to delete session
|
||||
response = HttpResponseRedirect(request.build_absolute_uri(exit_url))
|
||||
request.session.clear()
|
||||
|
||||
response = HttpResponseRedirect(exit_url)
|
||||
|
||||
if authenticator:
|
||||
authenticator.webLogoutHook(username, request, response)
|
||||
return response
|
||||
|
@ -394,10 +394,14 @@ class ProxmoxClient:
|
||||
|
||||
@ensureConected
|
||||
def stopVm(self, vmId: int, node: typing.Optional[str] = None) -> types.UPID:
|
||||
# if exitstatus is "OK" or contains "already running", all is fine
|
||||
node = node or self.getVmInfo(vmId).node
|
||||
return types.UPID.fromDict(self._post('nodes/{}/qemu/{}/status/stop'.format(node, vmId)))
|
||||
|
||||
@ensureConected
|
||||
def resetVm(self, vmId: int, node: typing.Optional[str] = None) -> types.UPID:
|
||||
node = node or self.getVmInfo(vmId).node
|
||||
return types.UPID.fromDict(self._post('nodes/{}/qemu/{}/status/reset'.format(node, vmId)))
|
||||
|
||||
@ensureConected
|
||||
def suspendVm(self, vmId: int, node: typing.Optional[str] = None) -> types.UPID:
|
||||
# if exitstatus is "OK" or contains "already running", all is fine
|
||||
|
@ -167,7 +167,7 @@ class ProxmoxDeployment(services.UserDeployment):
|
||||
o Proxmox, reset operation just shutdowns it until v3 support is removed
|
||||
"""
|
||||
if self._vmid != '':
|
||||
self.service().stopMachine(int(self._vmid))
|
||||
self.service().resetMachine(int(self._vmid))
|
||||
|
||||
def getConsoleConnection(self) -> typing.Optional[typing.MutableMapping[str, typing.Any]]:
|
||||
return self.service().getConsoleConnection(self._vmid)
|
||||
|
@ -143,6 +143,9 @@ class ProxmoxProvider(services.ServiceProvider): # pylint: disable=too-many-pub
|
||||
def stopMachine(self, vmId: int) -> client.types.UPID:
|
||||
return self.__getApi().stopVm(vmId)
|
||||
|
||||
def resetMachine(self, vmId: int) -> client.types.UPID:
|
||||
return self.__getApi().resetVm(vmId)
|
||||
|
||||
def suspendMachine(self, vmId: int) -> client.types.UPID:
|
||||
return self.__getApi().suspendVm(vmId)
|
||||
|
||||
|
@ -242,6 +242,9 @@ class ProxmoxLinkedService(Service): # pylint: disable=too-many-public-methods
|
||||
def stopMachine(self, vmId: int) -> 'client.types.UPID':
|
||||
return self.parent().stopMachine(vmId)
|
||||
|
||||
def resetMachine(self, vmId: int) -> 'client.types.UPID':
|
||||
return self.parent().resetMachine(vmId)
|
||||
|
||||
def suspendMachine(self, vmId: int) -> 'client.types.UPID':
|
||||
return self.parent().suspendMachine(vmId)
|
||||
|
||||
|
@ -72,6 +72,7 @@ def authCallback(request: HttpRequest, authName: str) -> HttpResponse:
|
||||
authenticator = Authenticator.objects.get(name=authName)
|
||||
params = request.GET.copy()
|
||||
params.update(request.POST)
|
||||
params['_query'] = request.META.get('QUERY_STRING', '')
|
||||
|
||||
logger.debug('Auth callback for %s with params %s', authenticator, params.keys())
|
||||
|
||||
@ -110,9 +111,9 @@ def authCallback_stage2(request: HttpRequest, ticketId: str) -> HttpResponse:
|
||||
|
||||
return response
|
||||
except auths.exceptions.Redirect as e:
|
||||
return HttpResponseRedirect(request.build_absolute_uri(str(e)))
|
||||
return HttpResponseRedirect(request.build_absolute_uri(str(e)) if e.args and e.args[0] else '/' )
|
||||
except auths.exceptions.Logout as e:
|
||||
return webLogout(request, request.build_absolute_uri(str(e)))
|
||||
return webLogout(request, request.build_absolute_uri(str(e)) if e.args and e.args[0] else None)
|
||||
except Exception as e:
|
||||
logger.exception('authCallback')
|
||||
return errors.exceptionView(request, e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user