> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 目标地址认证

> 只需为目标地址注册一次认证（HMAC 签名凭证或 mTLS 客户端证书），PCI Proxy 便会为您认证每一次转发。密钥材料仅可写入，并在静态存储时加密。

您无需在每次转发时发送签名凭证，而是可以为
已加入允许列表的目标地址一次性附加认证。此后，发往该主机的所有转发都会由
代理自动认证：使用 HMAC 签名、出示您的 mTLS 客户端证书，或两者兼有。

目前支持两种认证类型，并且可以在同一个目标地址上组合使用：

| 类型 | 代理在每次转发时执行的操作 |
| - | - |
| `DLOCAL_HMAC` | 使用您的 dLocal 凭证对发出的请求进行签名：设置 `X-Login`、`X-Trans-Key`、`X-Date` 以及 `Authorization` HMAC 签名 |
| `MTLS` | 在与目标地址进行 TLS 握手时出示您的客户端证书 |

> [!NOTE]
>
> **您的密钥仅可写入**
>
> 密钥材料（签名密钥和私钥）在注册时接收，并且任何 endpoint 都不会
> 返回它们。它们在存储前使用专用的 KMS 密钥加密；
> 明文仅在请求签名期间存在于内存中。读取操作只返回
> 非机密材料：`x_login` 标识符，或证书的 fingerprint 和过期时间。

## 优先级：每个请求的标头始终优先

[每个请求的签名标头](https://docs.y.uno/zh-hans/docs/security-and-compliance/pci-proxy/forward-proxy.md#signed-destinations-hmac-request-signing)
（`yuno-proxy-auth` + `yuno-proxy-auth-secret-key`）与之前完全一样继续有效。在任何
转发中：

1. 如果请求携带 `yuno-proxy-auth*` 标头，则使用这些凭证。
2. 否则，如果目标地址有已保存的配置，代理会使用该配置。
3. 否则，请求将不经认证直接转发，作为普通的允许列表条目处理。

应用已保存的 `DLOCAL_HMAC` 配置时，代理会根据该配置设置全部四个标头
（`X-Login`、`X-Trans-Key`、`X-Date`、`Authorization`），您在该请求中为
这些标头发送的值会被替换。只要
目标地址具有 `MTLS` 配置，就会出示 mTLS 证书，无论请求如何签名。

如果同一主机名既在组织范围内注册，又为特定账户注册，那么对于携带该
`yuno-account-id` 的请求，账户范围的目标地址（及其认证）
优先。

## 注册带认证的目标地址

在[目标地址注册](https://docs.y.uno/zh-hans/docs/security-and-compliance/pci-proxy/allowlist.md#register-a-destination)中添加 `authentication` 数组，
每种类型最多一个条目：

```sh theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl -X POST "https://api.y.uno/v1/pci-proxy/destinations" \
  -H "public-api-key: $PUBLIC_API_KEY" \
  -H "private-secret-key: $PRIVATE_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "hostname": "api.dlocal.com",
    "purpose": "Direct payins - dLocal",
    "authentication": [
      {
        "type": "DLOCAL_HMAC",
        "x_login": "sak_live_...",
        "x_trans_key": "...",
        "secret_key": "..."
      }
    ]
  }'
```

mTLS 条目以 PEM 格式携带证书及其私钥。证书可以
包含中间证书；私钥仅可写入：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "type": "MTLS",
  "certificate": "-----BEGIN CERTIFICATE-----\n...",
  "private_key": "<your PEM private key>"
}
```

响应（与对该目标地址的每次读取一样）只返回非机密材料：

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "hostname": "api.dlocal.com",
  "status": "ENABLED",
  "authentication": [
    { "type": "DLOCAL_HMAC", "x_login": "sak_live_..." },
    {
      "type": "MTLS",
      "certificate_fingerprint": "sha256:9f86d081...",
      "certificate_expires_at": "2027-01-01T00:00:00Z"
    }
  ]
}
```

无效配置会返回 `422 INVALID_AUTHENTICATION`：未知的 `type`、重复的
`type`、缺失或为空的必填字段、意外的字段、无法
解析的证书或密钥、与证书不匹配的密钥，或已过期的证书。

## 轮换凭证

轮换是对目标地址认证的完整替换：请发送完整的新
配置；不支持部分修补：

```sh theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl -X PUT "https://api.y.uno/v1/pci-proxy/destinations/{id}/authentication" \
  -H "public-api-key: $PUBLIC_API_KEY" \
  -H "private-secret-key: $PRIVATE_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "authentication": [
      { "type": "DLOCAL_HMAC", "x_login": "sak_live_new", "x_trans_key": "...", "secret_key": "..." }
    ]
  }'
```

返回 `200` 以及目标地址和其新的认证摘要。覆盖操作具有
幂等性，并立即生效：下一次转发就会使用新凭证。
请在读取时使用 `certificate_expires_at`，以便在证书过期前安排轮换。

## 移除认证

```sh theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl -X DELETE "https://api.y.uno/v1/pci-proxy/destinations/{id}/authentication" \
  -H "public-api-key: $PUBLIC_API_KEY" \
  -H "private-secret-key: $PRIVATE_SECRET_KEY"
```

返回 `200`。目标地址继续作为普通的允许列表条目工作；发往它的转发
只是不再由代理认证。删除目标地址本身也会移除其
认证。

每次认证变更都会以 `AUTH_SET` 或
`AUTH_REMOVED` 的形式记录在目标地址审计日志中。

## 错误

| 状态 | 代码 | 何时发生 |
| - | - | - |
| `400` | `INVALID_PARAMETERS` | 请求体格式错误、`PUT` 时 `authentication` 数组为空，或目标地址 id 无效 |
| `404` | `NOT_FOUND` | 目标地址不存在，或对您的账户范围不可见 |
| `422` | `INVALID_AUTHENTICATION` | 认证配置无效（静态消息；不会披露具体原因） |
| `502` | `DESTINATION_UNREACHABLE` | 转发时：目标地址拒绝了 TLS 握手。请检查您的客户端证书是否为目标地址期望的证书，以及是否已过期 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.