|
@@ -19,9 +19,10 @@ from django.views import View
|
|
|
|
|
|
from Model.models import KVS, Device_User, Device_Info
|
|
|
from Object.AWS.AmazonKinesisVideoUtil import AmazonKinesisVideoObject, AmazonKVAMObject
|
|
|
+from Object.IOTCore.IotObject import IOTClient
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
-from Ansjer.config import ACCESS_KEY_ID, SECRET_ACCESS_KEY, SERVER_DOMAIN, LOGGER, KVS_REGION
|
|
|
+from Ansjer.config import ACCESS_KEY_ID, SECRET_ACCESS_KEY, SERVER_DOMAIN, LOGGER, KVS_REGION, REGION_ID_LIST
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from botocore.auth import SigV4Auth
|
|
|
from botocore.awsrequest import AWSRequest
|
|
@@ -534,10 +535,19 @@ class KVSView(View):
|
|
|
if not all([serial]):
|
|
|
return response.json(444)
|
|
|
try:
|
|
|
+ # 获取并判断region_id是否有效
|
|
|
+ region_id = CommonService.confirm_region_id()
|
|
|
+ if region_id not in REGION_ID_LIST:
|
|
|
+ return response.json(444, {'invalid region_id': region_id})
|
|
|
+ # 获取iot:CredentialProvider
|
|
|
+ endpoint_type = 'iot:CredentialProvider'
|
|
|
+ iot_client = IOTClient(region_id)
|
|
|
+ iot_credential_provider_endpoint = iot_client.describe_iot_endpoint(endpoint_type)
|
|
|
# 已有数据直接返回
|
|
|
res = {
|
|
|
'region': KVS_REGION,
|
|
|
- 'role_alias': 'KvsCameraIoTRoleAlias'
|
|
|
+ 'role_alias': 'KvsCameraIoTRoleAlias',
|
|
|
+ 'iot_credential_provider_endpoint': iot_credential_provider_endpoint,
|
|
|
}
|
|
|
kvs = KVS.objects.filter(channel_name=serial)
|
|
|
if kvs.exists():
|