Chuyển tới nội dung chính

Xác thực

Mọi lệnh API dùng token Keystone trong header X-Auth-Token. Lấy token từ POST /v3/auth/tokens.

Application credential​

Dùng application credential cho script và CI. Credential đã gắn với project và không cần mã TOTP.

Tạo credential trong console Vietnix Enterprise Cloud, xem API credentials.

Request mẫu​

curl -ksD - -o /dev/null -X POST \
-H 'Content-Type: application/json' \
-d '{
"auth": {
"identity": {
"methods": ["application_credential"],
"application_credential": {
"id": "<credential-id>",
"secret": "<credential-secret>"
}
}
}
}' \
https://api.vietnix.cloud/v3/auth/tokens
POST https://api.vietnix.cloud/v3/auth/tokens
Content-Type: application/json

Response là 201 Created. Token nằm trong header X-Subject-Token:

HTTP/1.1 201 CREATED
X-Subject-Token: gAAAAA<...>

Credential đã có scope, nên không cần block scope.

Password​

Đăng nhập bằng password dùng cho thao tác tương tác. Nếu tài khoản bật 2FA, truyền mã TOTP hợp lệ hoặc dùng application credential.

Request mẫu​

curl -ksD - -o /dev/null -H 'Content-Type: application/json' -d '
{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "user-1234",
"domain": {
"id": "921940ee9d6c465daa555fcc3e3764a2"
},
"password": "password1234"
}
}
},
"scope": {
"project": {
"name": "project-1234",
"domain": {
"id": "921940ee9d6c465daa555fcc3e3764a2"
}
}
}
}
}' https://api.vietnix.cloud/v3/auth/tokens

Dùng token​

TOKEN=$(curl -ksD - -o /dev/null -X POST \
-H 'Content-Type: application/json' \
-d @auth.json https://api.vietnix.cloud/v3/auth/tokens \
| awk -F': ' 'tolower($1)=="x-subject-token"{print $2}' | tr -d '\r')

curl -ks -H "X-Auth-Token: $TOKEN" \
https://api.vietnix.cloud:8774/v2.1/servers

Không commit credential hoặc token. CLI lưu cùng giá trị trong openrc hoặc clouds.yaml.