in aliyun-net-credentials/Provider/ProfileCredentialsProvider.cs [154:192]
public CredentialModel GetSTSAssumeRoleSessionCredentials(Dictionary<string, string> clientConfig)
{
string accessKeyId = DictionaryUtil.Get(clientConfig, AuthConstant.IniAccessKeyId);
string accessKeySecret = DictionaryUtil.Get(clientConfig, AuthConstant.IniAccessKeyIdsecret);
string roleSessionName = DictionaryUtil.Get(clientConfig, AuthConstant.IniRoleSessionName);
string roleArn = DictionaryUtil.Get(clientConfig, AuthConstant.IniRoleArn);
string regionId = DictionaryUtil.Get(clientConfig, AuthConstant.DefaultRegion);
string policy = DictionaryUtil.Get(clientConfig, AuthConstant.IniPolicy);
string stsRegionId = DictionaryUtil.Get(clientConfig, AuthConstant.iniStsRegionId);
string externalId = DictionaryUtil.Get(clientConfig, AuthConstant.iniExternalId);
string enable = DictionaryUtil.Get(clientConfig, AuthConstant.IniEnable);
bool? enableVpc = enable == null ? (bool?)null
: enable.ToLower() == "true" ? true
: enable.ToLower() == "false" ? false
: (bool?)null;
if (string.IsNullOrWhiteSpace(accessKeyId) || string.IsNullOrWhiteSpace(accessKeySecret))
{
throw new CredentialException("The configured access_key_id or access_key_secret is empty");
}
if (string.IsNullOrWhiteSpace(roleSessionName) || string.IsNullOrWhiteSpace(roleArn))
{
throw new CredentialException("The configured role_session_name or role_arn is empty");
}
RamRoleArnCredentialProvider provider = new RamRoleArnCredentialProvider.Builder()
.AccessKeyId(accessKeyId)
.AccessKeySecret(accessKeySecret)
.RoleSessionName(roleSessionName)
.RoleArn(roleArn)
.RegionId(regionId)
.Policy(policy)
.StsRegionId(stsRegionId)
.EnableVpc(enableVpc)
.ExternalId(externalId)
.Build();
return provider.GetCredentials();
}