Add payload to ditribute o2ims api token to smo side. 79/9379/3
authordliu5 <david.liu@windriver.com>
Mon, 24 Oct 2022 07:34:12 +0000 (15:34 +0800)
committerdliu5 <david.liu@windriver.com>
Tue, 25 Oct 2022 03:22:52 +0000 (11:22 +0800)
The token is follow below rfc:

https://www.rfc-editor.org/rfc/rfc7519

Doc Ref:

https://jwt.io/introduction

Signed-off-by: dliu5 <david.liu@windriver.com>
Change-Id: I0b850b3c7428c2f70e0eb19768e38a8b86607d12

configs/o2app.conf
o2ims/service/command/registration_handler.py

index 7a97437..6ee900a 100644 (file)
@@ -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"
 
index 40cd390..fd37457 100644 (file)
@@ -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'}