Commit fcfdfa4f authored by Ivan Tyagov's avatar Ivan Tyagov

Use username / password to authenticate against ERP5 backend.

parent 853ba03f
......@@ -23,11 +23,15 @@ a('--ip', help='The IP address on which the OPCUA Server runs', default="127.0.0
a('--port', help='The port on which the OPCUA Server runs', default="4840")
a('--xml', help='Path of XML to configure Server. See asyncua doc for more details.', default=None)
a('--erp5-url', help='URL of ERP5 instance to which data shall be send.', default=None)
a('--erp5-username', help='Username of ERP5 instance to which data shall be send.', default=None)
a('--erp5-password', help='Password of ERP5 instance to which data shall be send.', default=None)
args = parser.parse_args()
ip = args.ip
port = args.port
xml = args.xml
erp5_url = args.erp5_url
erp5_username = args.erp5_username
erp5_password = args.erp5_password
ERP5_REQUEST_API = "ERP5Site_handleOPCUARequest"
@dataclass(frozen=True)
......@@ -42,6 +46,7 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
def call(self, http_method = "POST", **data):
params = urllib.parse.quote_plus(json.dumps({k: str(v) for k, v in data.items()}))
self.session.auth = (erp5_username, erp5_password)
if http_method == "POST":
self.session.post(f"{self.uri}?data={params}")
elif http_method == "GET":
......
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