R&Dプラットフォームまたはツールプラットフォームのデータ管理 (DMS) コンソールに、ログオンなしのURLを埋め込むことができます。 これにより、Alibaba Cloudアカウントで、またはResource access Management (RAM) ユーザーとしてDMSコンソールにログインすることなく、DMSコンソールにアクセスしてその機能を使用できます。 このトピックでは、DMSコンソールにログイン不要のURLを作成する方法について説明します。
手順
DMSにアクセスするために使用されるRAMロールを作成し、ロールに権限を付与します。 次に、RAMユーザーを作成し、AliyunSTSAssumeRoleAccess権限をユーザーに付与します。 詳細については、「 準備」をご参照ください。
AccessKey ID、AccessKeyシークレット、およびセキュリティトークンなど、引き受けたロールの一時的なID資格情報を取得します。 これらの資格情報は、SigninTokenを取得するために使用されます。 詳細については、「手順1: 引き受けたロールの一時的なID資格情報の取得」をご参照ください。
ログオンなしのURLを作成するために使用されるSigninTokenを取得します。 詳細については、「手順2: SigninTokenの取得」をご参照ください。
ログオンなしのURLを作成します。 詳細については、「手順3: DMSコンソールへのログイン不要URLの作成」をご参照ください。
次の例は、サンプルJavaコードを示しています:
/*
Create a RAM user and grant permissions to the user.
*/
String accountId = "Alibaba Cloud account";
// The role used to access DMS. You can grant the AliyunDMSReadOnlyAccess and AliyunDMSFullAccess permissions to this role as needed.
String ramRole = "The RAM role that you have created";
// The AccessKey ID and AccessKey secret for the RAM user and the AliyunSTSAssumeRoleAccess permission are required.
String accessKeyId = "";
String accessKeySecret = "";
/*
Step 1: Call the AssumeRole operation to obtain the temporary AccessKey ID, AccessKey secret, and security token.
*/
AssumeRoleResponse.Credentials credentials = assumeRole(accountId, accessKeyId, accessKeySecret, ramRole);
System.out.println("Expiration: " + credentials.getExpiration());
System.out.println("Access Key Id: " + credentials.getAccessKeyId());
System.out.println("Access Key Secret: " + credentials.getAccessKeySecret());
System.out.println("Security Token: " + credentials.getSecurityToken());
/*
Step 2: Obtain a SigninToken.
*/
String signInToken = getSignInToken(credentials.getAccessKeyId(),
credentials.getAccessKeySecret(),
credentials.getSecurityToken());
System.out.println("Your SigninToken is: " + signInToken);
/*
Step 3: Create a logon-free URL. The URL to the homepage of the DMS console is used in this example.
*/
String pageUrl = getDmsLoginUrl("https://dms.aliyun.com", signInToken);
System.out.println("Your PageUrl is : " + pageUrl);
準備
次の条件をすべて満たしている場合は、以下の手順1、2、および3を実行します。
DMSへのアクセスに使用するRAMロールを作成します。 詳細については、「信頼できるAlibaba CloudアカウントのRAMロールの作成」をご参照ください。
RAMロールに権限を付与します。 詳細については、「RAMロールへの権限の付与」をご参照ください。
RAM ユーザーを作成します。 詳細については、「RAM ユーザーの作成」をご参照ください。
RAMユーザーにAliyunSTSAssumeRoleAccess権限を付与します。 詳細については、「RAM ユーザーへの権限の付与」をご参照ください。
手順1: 引き受けたロールの一時的なID資格情報を取得する
AssumeRole操作をRAMユーザーまたはRAMロールとして呼び出して、担当するロールの一時的なID資格情報を取得します。 AssumeRole操作の詳細については、「AssumeRole」をご参照ください。
次の例は、サンプルのJavaコードを示しています。
/**
* Call the AssumeRole operation to obtain temporary identity credentials for the user
*
* @param accountId
* @param accessKeyId
* @param accessKeySecret
* @param ramRole
* @return
* @throws ClientException
*/
private static AssumeRoleResponse.Credentials assumeRole(String accountId, String accessKeyId,
String accessKeySecret, String ramRole)
throws ClientException {
String defaultRegion = "cn-hangzhou";
IClientProfile profile = DefaultProfile.getProfile(defaultRegion, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
AssumeRoleRequest request = new AssumeRoleRequest();
// An Alibaba Cloud Resource Name (ARN) is the globally unique resource identifier of a RAM role.
request.setRoleArn(getRoleArn(accountId, ramRole));
// The user-defined parameter. You can audit access of users who use different security tokens based on the value of this parameter. The value format is ^[a-zA-Z0-9\.@\-_]+$.
request.setRoleSessionName("session-name");
// The specified validity period. Unit: seconds. Valid values: 900 to 3600. Default value: 3600.
request.setDurationSeconds(3600L);
AssumeRoleResponse response = client.getAcsResponse(request);
return response.getCredentials();
}
ステップ2: SigninTokenを取得する
GetSigninToken操作を呼び出してSigninTokenを取得します。」をご参照ください。
次の例は、サンプルのJavaコードを示しています。
/**
* Use a security token to obtain a SigninToken.
*
* @param accesskeyId
* @param accessKeySecret
* @param securityToken
* @return
* @throws IOException
* @throws URISyntaxException
*/
private static String getSignInToken(String accesskeyId, String accessKeySecret, String securityToken)
throws IOException, URISyntaxException {
URIBuilder builder = new URIBuilder(SIGN_IN_DOMAIN);
builder.setParameter("Action", "GetSigninToken")
.setParameter("AccessKeyId", accesskeyId)
.setParameter("AccessKeySecret", accessKeySecret)
.setParameter("SecurityToken", securityToken)
.setParameter("TicketType", "normal");
HttpGet request = new HttpGet(builder.build());
CloseableHttpClient httpclient = HttpClients.createDefault();
try (CloseableHttpResponse response = httpclient.execute(request)) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String context = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSON.parseObject(context);
return jsonObject.getString("SigninToken");
} else {
System.out.println(response.getStatusLine());
}
}
return null;
}
ステップ3: DMSコンソールへのログオン不要URLの作成
取得したSigninTokenは、ログオンなしのURLを作成するために1回のみ使用できます。 SigninTokenを再度使用する必要がある場合は、新しいSigninTokenを取得する必要があります。
次の例は、サンプルJavaコードを示しています。
サンプルリクエスト:
private static String getDmsLoginUrl(String pageUrl, String signInToken) throws URISyntaxException {
URIBuilder builder = new URIBuilder(SIGN_IN_DOMAIN);
builder.setParameter("Action", "Login");
// Specify the logon URL on the self-managed website that is configured to return HTTP status code 302 to redirect to another page.
builder.setParameter("LoginUrl", "https://signin.aliyun.com/login.htm");
// The DMS page to be actually accessed.
builder.setParameter("Destination", pageUrl);
builder.setParameter("SigninToken", signInToken);
HttpGet request = new HttpGet(builder.build());
return request.getURI().toString();
}
サンプル応答:
Expiration: 2020-11-30T06:16:20Z
Access Key Id: STS.NT7L6Jp5Y8W9LNvGQku2x****
Access Key Secret: 4nU8F6rv8MCDR8tygMDnXvN9yCNBCVrxnqArj1n1****
Security Token: CAIS/gF1q6Ft5B2yfSjIr5e****+nep4j5XSTmjHo1E+eb1Ujo7xijz2IH9IeXhpB****/43nWlU7PkYlrloRoReREvCKM1565kSqFn6O11Qf****+5qsoasPETOITyZtZagToeUZdfZfejXGDKgvyRvwLz****/Vli+S/OggoJmadJlNWvRL0AxZrFsKxBltdUROF****+pKWSKuGfLC1dysQcO4gEWq4bHm5zAs0OH1QOhlrVP+N+qfqLJNZc8YM1NNP6ux/Fze6b71ypd1gNH7q8ejtYfpmua74jBXgUAuU3faraOrYd1SwZ9Z7knH****/n6ifBjpvw9Hlk0R9OcVhqAAXpZx****+STGa8vctRwyTWdMM5LByes3cr1D46jaj0****/lTMkoXCwjMlCs7sc+DA9xjJCcl57eKC7A3ThnJAWQyyeKZfIGgeHN7yUS5ND8r7TBn6bMUqwvfVX****/cbkzBX6iV6jrataHZPZdtQYHH6GgvQ5XZUZJjoD****
Your SigninToken is: 06ec409b9d8c48f6ac5dcd18a0513ee1dhUkhcRn5CMsDqffC4wxsuFt9xjYtYePmYTHEWSMVKLFyXXnSq3IUbon1v46wCmKPwrAejDvw2i8rilolPSuxpKRDxz****
Your PageUrl is : http://signin.aliyun.com/federation?Action=Login&LoginUrl=https%3A%2F%2Fsignin.aliyun.com%2Flogin.htm&Destination=https%3A%2F%2Fdms.aliyun.com&SigninToken=06ec409b9d8c48f6ac5dcd18a0513ee1dhUkhcRn5CMsDqffC4wxsuFt9xjYtYePmYTHEWSMVKLFyXXnSq3IUbon1v46wCmKPwrAejDvw2i8rilolPSuxpKRDxzD****
次の例は、ログオンなしのURL (PageUrl) の形式を示してい http://signin.aliyun.com/federation?Action=Login 。
http://signin.aliyun.com/federation?Action=Login
&LoginUrl=<Logon URL on the self-managed website that is configured to return HTTP status code 302 to redirect to another page>
&Destination=<The DMS page to be actually accessed>
&SigninToken=<Obtained SigninToken>
Destinationで指定されたDMSページは、TicketTypeパラメーターに関連しています。
TicketTypeパラメーターがnormalに設定されている場合、対応するDMSドメイン名が
http://dms.aliyun.com
されます。TicketTypeパラメーターがminiに設定されている場合、通常はBID仮想ネットワークオペレーターに適用されます。 次のドメイン名が使用されます。
http://dms-jst4service.aliyun.com
http://dms-Itwo4service.aliyun.com
次のステップ
作成したログオン不要URL (PageUrl) を使用してDMSコンソールにアクセスします。