diff --git a/software/simpleran/buildout.hash.cfg b/software/simpleran/buildout.hash.cfg index 6b64375a7481444a322708144e18fa1515ade042..e707ab755c2df64eb67b56349f7b16d9d541478a 100644 --- a/software/simpleran/buildout.hash.cfg +++ b/software/simpleran/buildout.hash.cfg @@ -28,15 +28,15 @@ md5sum = 8d6eb90fc1191c3a1b24200df2ebf4fa [ru_amarisoft-stats.jinja2.py] _update_hash_filename_ = ru/amarisoft-stats.jinja2.py -md5sum = 31b609f80a82b6efed963161c8907878 +md5sum = 9075f5d5d6d453d02b4f284b7edabe41 [ru_amarisoft-rf-info.jinja2.py] _update_hash_filename_ = ru/amarisoft-rf-info.jinja2.py -md5sum = 93a5e07a763b619747255b4e03b50bbe +md5sum = 0a3a1ecde45a898502f1c66cb26b7d91 [ru_libinstance.jinja2.cfg] _update_hash_filename_ = ru/libinstance.jinja2.cfg -md5sum = f0d7d38ef486f5be44020c3d5ce2a94f +md5sum = e436824a4325636fcd479b9711a94044 [ru_sdr_libinstance.jinja2.cfg] _update_hash_filename_ = ru/sdr/libinstance.jinja2.cfg diff --git a/software/simpleran/ru/amarisoft-rf-info.jinja2.py b/software/simpleran/ru/amarisoft-rf-info.jinja2.py index 247eb0ddf2d192b4a14995ed25843fc51881ec89..8d9ccb6f23118a0962df5a21ff0ce435bb56cd76 100644 --- a/software/simpleran/ru/amarisoft-rf-info.jinja2.py +++ b/software/simpleran/ru/amarisoft-rf-info.jinja2.py @@ -1,5 +1,7 @@ #!{{ python_path }} import json +import hashlib +import hmac import logging from logging.handlers import RotatingFileHandler import time @@ -21,7 +23,20 @@ class enbWebSocket: if {{ testing }}: return - self.ws = create_connection("{{ ws_url }}") + self.ws_url = "{{ ws_url }}" + self.ws_password = "{{ ws_password }}" + self.ws = create_connection(self.ws_url) + + # Password authentication + data = json.loads(self.ws.recv()) + res = hmac.new( + "{}:{}:{}".format(data['type'], self.ws_password, data['name']).encode(), + msg=data['challenge'].encode(), + digestmod=hashlib.sha256 + ).hexdigest() + msg = {"message": "authenticate", "res": res} + self.ws.send(json.dumps(msg)) + self.ws.recv() def close(self): if {{ testing }}: diff --git a/software/simpleran/ru/amarisoft-stats.jinja2.py b/software/simpleran/ru/amarisoft-stats.jinja2.py index 7323eaa9b6188884fbf2d0c8d871af7c4783b74c..eda1bdf0911a5861374e4fa9c0f5515a28b59e95 100644 --- a/software/simpleran/ru/amarisoft-stats.jinja2.py +++ b/software/simpleran/ru/amarisoft-stats.jinja2.py @@ -27,6 +27,7 @@ class enbWebSocket: self.ws_password = "{{ ws_password }}" self.ws = create_connection(self.ws_url) + # Password authentication data = json.loads(self.ws.recv()) res = hmac.new( "{}:{}:{}".format(data['type'], self.ws_password, data['name']).encode(), diff --git a/software/simpleran/ru/libinstance.jinja2.cfg b/software/simpleran/ru/libinstance.jinja2.cfg index 477577a62a3b2df2ba4c0b95c39e5d10f5e18729..fccb8982af5ea40063db403395fb7e47ff03f015 100644 --- a/software/simpleran/ru/libinstance.jinja2.cfg +++ b/software/simpleran/ru/libinstance.jinja2.cfg @@ -328,6 +328,7 @@ context = key log_file :log-output raw stats_period {{ slapparameter_dict.get("enb_stats_fetch_period", 60) }} raw testing {{ testing }} + raw ws_password ${websocket-password:passwd} raw ws_url ws://{{ slapparameter_dict.com_addr }}:{{ slapparameter_dict.com_ws_port }} raw python_path {{ buildout_directory}}/bin/pythonwitheggs mode = 0775