From: dliu5 Date: Mon, 24 Oct 2022 07:34:12 +0000 (+0800) Subject: Add payload to ditribute o2ims api token to smo side. X-Git-Tag: 2.0.0-rc1~24^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=f5fd1d3fa262b7680839a020ed63390fa72a5599;p=pti%2Fo2.git Add payload to ditribute o2ims api token to smo side. The token is follow below rfc: https://www.rfc-editor.org/rfc/rfc7519 Doc Ref: https://jwt.io/introduction Signed-off-by: dliu5 Change-Id: I0b850b3c7428c2f70e0eb19768e38a8b86607d12 --- diff --git a/configs/o2app.conf b/configs/o2app.conf index 7a97437..6ee900a 100644 --- a/configs/o2app.conf +++ b/configs/o2app.conf @@ -2,7 +2,7 @@ ocloud_global_id = 4e24b97c-8c49-4c4f-b53e-3de5235a4e37 smo_register_url = http://127.0.0.1:8090/register - +smo_token_data = smo_token_payload [API] test = "hello" diff --git a/o2ims/service/command/registration_handler.py b/o2ims/service/command/registration_handler.py index 40cd390..fd37457 100644 --- a/o2ims/service/command/registration_handler.py +++ b/o2ims/service/command/registration_handler.py @@ -68,15 +68,25 @@ def register_smo(uow, ocloud_data): @retry((ConnectionRefusedError), tries=2, delay=2) def call_smo(reg_data: dict): + smo_token = conf.DEFAULT.smo_token_data + smo_token_info = { + 'iss': 'o2ims', + 'aud': 'smo', + 'smo_token_payload': smo_token, + 'smo_token_type': 'jwt', + 'smo_token_expiration': '', + 'smo_token_algo': 'RS256' + } + callback_data = json.dumps({ 'consumerSubscriptionId': reg_data['globalcloudId'], 'notificationEventType': 'CREATE', 'objectRef': config.get_api_url(), - 'postObjectState': reg_data + 'postObjectState': reg_data, + 'smo_token_data': smo_token_info }) logger.info('URL: {}, data: {}'.format( conf.DEFAULT.smo_register_url, callback_data)) - o = urlparse(conf.DEFAULT.smo_register_url) conn = http.client.HTTPConnection(o.netloc) headers = {'Content-type': 'application/json'}