Skip to content

Commit a4a64bb

Browse files
authored
Merge pull request #83 from AlibabaCloudLandingZone/solution-IDaaS-synchronization/0.0.1
solution-IDaaS-synchronization/0.0.1
2 parents 092876c + d215867 commit a4a64bb

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 基于函数计算实现从IdP到IDaaS的人员定时同步方案
2+
3+
本方案通过函数计算定时调用IDaaS同步的OpenAPI,来实现按照自定义周期进行人员自动从IdP到IDaaS同步。通过FC函数角色和RAM角色关联,使用STS Token访问云资源,避免了将访问密钥硬编码在代码中,从而消除AK泄露的风险。临时凭证(STS Token)的使用有效解决了永久凭证(AK/SK)可能带来的安全风险问题。 本方案提供Python代码示例,客户能够快速完成函数计算部署,减少开发和部署的复杂度。
4+
5+
## 如何运行
6+
该示例代码需要在FC函数中执行,请确保选择Python作为FC函数的运行环境。
7+
请您选择您的SDK类型对应的示例代码,复制代码后上传至函数计算运行即可。
8+
需要配置以下环境变量:
9+
{'IDAAS_EIAM_ENDPOINT',
10+
'INSTANCE_ID',
11+
'TARGET_ID',
12+
'TARGET_TYPE'
13+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
import logging
3+
import json
4+
import os
5+
import sys
6+
7+
from typing import List
8+
9+
from alibabacloud_eiam20211201.client import Client as Eiam20211201Client
10+
from alibabacloud_eiam20211201 import models as eiam_20211201_models
11+
from alibabacloud_tea_util import models as util_models
12+
from alibabacloud_credentials.client import Client as CredClient
13+
from alibabacloud_tea_openapi.models import Config
14+
15+
def handler(event, context):
16+
creds = context.credentials
17+
config = Config(access_key_id=creds.access_key_id,access_key_secret=creds.access_key_secret,security_token=creds.security_token)
18+
config.endpoint = os.environ['IDAAS_EIAM_ENDPOINT']
19+
client = Eiam20211201Client(config)
20+
21+
run_synchronization_job_request = eiam_20211201_models.RunSynchronizationJobRequest(
22+
instance_id=os.environ['INSTANCE_ID'],
23+
target_id=os.environ['TARGET_ID'],
24+
target_type=os.environ['TARGET_TYPE']
25+
)
26+
runtime = util_models.RuntimeOptions()
27+
response = client.run_synchronization_job_with_options(run_synchronization_job_request, runtime)
28+
29+
return(str(response.to_map()))

0 commit comments

Comments
 (0)