Commit d85df015 authored by ibuler's avatar ibuler

Merge branch 'dev' into test

parents ad8a9148 f689b5a3
......@@ -32,7 +32,7 @@ class BaseWebSocketHandler:
else:
remote_ip = request.remote_addr
self.clients[request.sid]["request"] = Request((remote_ip, 0))
self.clients[request.sid]["request"].user = self.get_current_user()
self.clients[request.sid]["request"].user = self.current_user
self.clients[request.sid]["request"].meta = {"width": self.clients[request.sid]["cols"],
"height": self.clients[request.sid]["rows"]}
# self.request.__dict__.update(request.__dict__)
......@@ -41,9 +41,6 @@ class BaseWebSocketHandler:
self.app.clients.append(self.clients[request.sid]["client"])
self.clients[request.sid]["forwarder"] = ProxyServer(self.app, self.clients[request.sid]["client"])
def get_current_user(self):
return User(id='61c39c1f5b5742688180b6dda235aadd', username="admin", name="admin")
def check_origin(self, origin):
return True
......@@ -78,7 +75,8 @@ class SSHws(Namespace, BaseWebSocketHandler):
"rw": []
}
join_room(room)
self.current_user = self.app.service.check_user_cookie(session_id=request.cookies.get('sessionid', ''),
csrf_token=request.cookies.get('csrftoken', ''))
self.prepare(request)
def on_data(self, message):
......@@ -162,4 +160,3 @@ class HttpServer:
def shutdown(self):
pass
......@@ -69,7 +69,8 @@ class ProxyServer:
def get_server_conn(self, asset, system_user):
logger.info("Connect to {}".format(asset.hostname))
if not self.validate_permission(asset, system_user):
self.client.send(warning(_('No permission')))
# self.client.send(warning(_('No permission')))
self.client.send(warning('No permission'))
return None
self.get_system_user_auth(system_user)
if True:
......
......@@ -5,6 +5,7 @@ import threading
import uuid
import logging
import datetime
import time
import selectors
import time
......@@ -20,7 +21,7 @@ class Session:
self._watchers = [] # Only watch session
self._sharers = [] # Join to the session, read and write
self.replaying = True
self.date_created = datetime.datetime.now()
self.date_created = datetime.datetime.utcnow()
self.date_end = None
self.stop_evt = threading.Event()
self.sel = selectors.DefaultSelector()
......@@ -160,7 +161,7 @@ class Session:
logger.info("Close the session: {} ".format(self.id))
self.stop_evt.set()
self.post_bridge()
self.date_end = datetime.datetime.now()
self.date_end = datetime.datetime.utcnow()
self.server.close()
def to_json(self):
......@@ -171,8 +172,8 @@ class Session:
"system_user": self.server.system_user.username,
"login_from": "ST",
"is_finished": True if self.stop_evt.is_set() else False,
"date_start": self.date_created.strftime("%Y-%m-%d %H:%M:%S"),
"date_end": self.date_end.strftime("%Y-%m-%d %H:%M:%S") if self.date_end else None
"date_start": self.date_created.strftime("%Y-%m-%d %H:%M:%S") + " +0000",
"date_end": self.date_end.strftime("%Y-%m-%d %H:%M:%S") + " +0000" if self.date_end else None
}
def __str__(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment