Todos os produtos
Search
Central de documentação

Data Management:Acesso sem login ao console do DMS

Última atualização: Jun 27, 2026

Incorpore uma URL na sua plataforma de desenvolvimento ou ferramentas para fornecer acesso sem login ao console do Data Management (DMS). Assim, os usuários acessam diretamente o console do DMS e seus recursos sem precisar entrar com uma conta Alibaba Cloud ou como usuário RAM. Este tópico descreve como crie uma URL para acesso sem login.

Procedimento

  1. Crie uma função RAM para acessar o DMS e conceda as permissões necessárias. Em seguida, crie um usuário RAM e conceda a ele a permissão AliyunSTSAssumeRoleAccess. Para mais informações, consulte Pré-requisitos.

  2. Obtenha credenciais temporárias ao assumir a função. Use essas credenciais (AccessKey ID, AccessKey Secret e token de segurança) para obter um SigninToken. Para mais informações, consulte Etapa 1: Obter credenciais temporárias.

  3. Obtenha um SigninToken, necessário para criar a URL de acesso sem login. Para mais informações, consulte Etapa 2: Obter um SigninToken.

  4. Crie a URL de acesso sem login. Para mais informações, consulte Etapa 3: Criar a URL de acesso sem login.

Maven dependencies

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>sts20150401</artifactId>
    <version>1.1.7</version>
</dependency>

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>2.0.53</version>
</dependency>

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.14</version>
</dependency>

Java code example

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.sts20150401.Client;
import com.aliyun.sts20150401.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.net.URISyntaxException;

/*
  Set up the user and role information.
 */
  String accountId = "Your Alibaba Cloud account ID";
 // The RAM role used to access DMS. Grant the AliyunDMSReadOnlyAccess (read-only) or AliyunDMSFullAccess permission as needed.
  String ramRoleArn = "The ARN of the RAM role that you created in the Prerequisites section";
 // The AccessKey ID and AccessKey Secret of the RAM user. The RAM user must have the AliyunSTSAssumeRoleAccess permission.
  String accessKeyId = "";
  String accessKeySecret = "";
 /*
  Step 1: Call the AssumeRole operation to obtain temporary credentials, including an AccessKey ID, an AccessKey Secret, and a security token.
 */
  AssumeRoleResponse.AssumeRoleResponseBodyCredentials credentials = assumeRole(accountId, accessKeyId, accessKeySecret, ramRoleArn);
  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 the SigninToken.
  */
  String signInToken = getSignInToken(credentials.getAccessKeyId(),
  credentials.getAccessKeySecret(),
  credentials.getSecurityToken());
  System.out.println("Your SigninToken is: " + signInToken);

 /*
  Step 3: Create the logon-free access URL. The following example uses the DMS console homepage.
 */
  String pageUrl = getDmsLoginUrl("https://dms.aliyun.com", signInToken);
  System.out.println("Your PageUrl is : " + pageUrl);

Pré-requisitos

Nota

Se você atender a todos os pré-requisitos abaixo, prossiga para a Etapa 1.

Etapa 1: Obter credenciais temporárias

Chame a operação AssumeRole para obter credenciais temporárias ao assumir uma função RAM. Para mais informações sobre a operação AssumeRole, consulte AssumeRole.

Exemplo de código Java:

  /**
  * Obtains temporary credentials by calling the AssumeRole operation.
  */
  private static AssumeRoleResponse.AssumeRoleResponseBodyCredentials assumeRole(
                    String accountId, String accessKeyId,
                    String accessKeySecret, String ramRoleArn) throws Exception {
    // Configure the STS client.
    Config config = new Config()
        .setAccessKeyId(accessKeyId)
        .setAccessKeySecret(accessKeySecret)
        // Note: The endpoint for Security Token Service (STS) is globally fixed. The sts.cn-hangzhou.aliyuncs.com endpoint is typically used.
        .setEndpoint("sts.cn-hangzhou.aliyuncs.com");
    Client client = new Client(config);
    AssumeRoleRequest request = new AssumeRoleRequest();
    // An ARN (Alibaba Cloud Resource Name) is a global resource identifier that specifies a RAM role.
    request.setRoleArn(ramRoleArn);
    // A custom parameter to distinguish between different tokens. This parameter can be used for user-level access auditing. Format: ^[a-zA-Z0-9\.@\-_]+$
    request.setRoleSessionName("session-name");
    request.setDurationSeconds(3600L); // Explicitly set the validity period in seconds.
    RuntimeOptions runtime = new RuntimeOptions();
    AssumeRoleResponse response = client.assumeRoleWithOptions(request, runtime);
    return response.getBody().getCredentials();
  }

Etapa 2: Obter um SigninToken

Chame a operação GetSigninToken para obter um SigninToken.

Exemplo de código Java:

  /**
     * Obtains a SigninToken by using a security token.
     *
     * @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("http://signin.aliyun.com/federation");

        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;
    }

Etapa 3: Criar a URL de acesso sem login

Nota

Cada SigninToken é de uso único. Para criar outra URL de acesso sem login, obtenha um novo token.

Exemplo de código Java:

Exemplo de solicitação:

private static String getDmsLoginUrl(String pageUrl, String signInToken) throws URISyntaxException {
        URIBuilder builder = new URIBuilder("http://signin.aliyun.com/federation");
        builder.setParameter("Action", "Login");
        // The URL to which the user is redirected when the session expires. This is typically a URL on your web server that is configured for a 302 redirect.
        builder.setParameter("LoginUrl", "https://signin.aliyun.com/login.htm");
        // The DMS page that the user accesses.
        builder.setParameter("Destination", pageUrl);
        builder.setParameter("SigninToken", signInToken);
        HttpGet request = new HttpGet(builder.build());
        return request.getURI().toString();
}

Exemplo de resposta:

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****

O exemplo a seguir mostra o formato da URL de acesso sem login (PageUrl):

http://signin.aliyun.com/federation?Action=Login
                            &LoginUrl=<your-redirect-url-on-expiration>
                            &Destination=<your-target-dms-url>
                            &SigninToken=<your-signin-token>
Nota

A URL da página do DMS no parâmetro Destination depende do valor de TicketType.

  • Se o valor for normal, o domínio correspondente do DMS será http://dms.aliyun.com.

  • Se o valor for mini, geralmente usado para operadores virtuais BID, o domínio correspondente será http://dms-ent4service.aliyun.com.

Próximas etapas

Abra a URL de acesso sem login (PageUrl) para acessar o console do DMS. Após o login, a identidade do usuário aparece no canto superior direito do console do DMS no formato {nome da função RAM}/{RoleSessionName}, por exemplo, aliyunlogintest/session-name-123.