跳到內容

身份驗證

TCS 根據你呼叫的端點使用三種身份驗證方式:

  • API Key — 在 X-API-Key header 中傳送的靜態金鑰。用於發行方和驗證方的管理操作。
  • Bearer JWT — 在 Authorization header 中傳送的 access token。用於 Trust Registry DID 操作和憑證請求。
  • DPoP(Demonstrating Proof-of-Possession) — RFC 9449 的持有證明機制,將 access token 綁定至客戶端的金鑰對,防範 token 竊取和重播。DPoP 是逐 token 決定的、不是部署層級的全域旗標 —— 個別 /credential 請求是否必須使用 DPoP,取決於 issuer 的簽章 profile 與 token 類型,不是一個全域開關。HAIP v1(X.509 / ES256 issuer)強制要求;EdDSA / DID 路徑為選用。詳見下方端點對照表。

大多數探索和協定端點為公開端點,無需身份驗證。

Rendering diagram...

Terminal window
curl -X POST https://issuer.turingspace.co/v1/offers \
-H "X-API-Key: tcs_production_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4" \
-H "Content-Type: application/json" \
-d '{
"credential": {
"config_id": "TuringCerts_Standard_Credential_v2_sd_jwt",
"claims": { "credentialName": "University Degree" }
},
"flow": "pre-authorized"
}'

X-API-Key header 中傳送你的 API 金鑰。組織透過 Trust Registry onboarding 由 TCS 團隊處理 — 沒有 self-service apply API,請聯絡我們註冊。核准後即可取得 API 金鑰。伺服器在儲存前以 SHA-256 對你的金鑰進行雜湊處理 — 明文金鑰永不持久化。

詳情
HeaderX-API-Key: {your_api_key}
格式tcs_{environment}_{48-hex}(例如 tcs_production_...
取得方式Trust Registry onboarding(由 TCS 團隊處理)
儲存方式僅儲存 SHA-256 雜湊值;明文不儲存
範圍發行方管理操作、驗證方管理操作
方法端點服務
POST/v1/offersCredential Issuer
POST/v1/verifier/authorization-requestVerifier Service
GET/v1/verifier/result/:sessionIdVerifier Service
狀態碼訊息原因
401API Key is required缺少 X-API-Key header
401Invalid API Key金鑰未找到或雜湊不符
401Account is not approved金鑰有效但帳號等待核准中

Terminal window
# Trust Registry DID 操作(來自登入的 token)
curl -X POST https://trust-registry.turingspace.co/v1/did \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9..." \
-H "Content-Type: application/json" \
-d '{ "did": "did:key:z6Mk..." }'
Terminal window
# 憑證請求(來自 token 端點的 token)
curl -X POST https://issuer.turingspace.co/credential \
-H "Authorization: Bearer eyJhbGciOiJFUzI1NiJ9..." \
-H "Content-Type: application/json" \
-d '{
"credential_configuration_id": "EmployeeCredential_sd_jwt",
"proofs": {
"jwt": ["eyJhbGciOiJFZERTQSIs...proof-jwt"]
}
}'

Authorization: Bearer {token} header 中傳送 access token。根據操作不同,有兩個不同的 JWT 來源:

用途Token 來源取得方式
Trust Registry DID 操作登入 tokenPOST /v1/auth/login 傳送 uuid 和密碼
憑證請求Access tokenPOST /v1/token 傳送預授權碼
方法端點服務Token 來源
POST/v1/didTrust Registry登入 token
POST/v1/did/importTrust Registry登入 token
POST/credentialCredential IssuerToken 端點
狀態碼訊息原因
401invalid_tokenAccess token 無效或已過期
403Forbidden帳號未取得此操作的授權

3. DPoP(Demonstrating Proof-of-Possession)

Section titled “3. DPoP(Demonstrating Proof-of-Possession)”
Terminal window
# 第一步:建立 DPoP proof JWT
# Header
{
"typ": "dpop+jwt",
"alg": "ES256",
"jwk": { /* sender's public key */ }
}
# Payload
{
"jti": "unique-id-abc123",
"htm": "POST",
"htu": "https://issuer.turingspace.co/credential",
"iat": 1711411200,
"ath": "fUHyO2r2Z3DZ53EsNrWBb0xWXoaNy59IiKCAqksmQEo"
}
# 第二步:同時傳送兩個 header
curl -X POST https://issuer.turingspace.co/credential \
-H "Authorization: DPoP eyJhbGciOiJFUzI1NiJ9..." \
-H "DPoP: eyJ0eXAiOiJkcG9wK2p3dCJ9..." \
-H "Content-Type: application/json" \
-d '{
"credential_configuration_id": "EmployeeCredential_sd_jwt",
"proofs": {
"jwt": ["eyJhbGciOiJFZERTQSIs...proof-jwt"]
}
}'

DPoP(RFC 9449)將 access token 綁定至客戶端的金鑰對,讓被竊取的 token 無法被其他人使用。HAIP v1 要求,建議所有憑證端點互動都使用。需要兩個 header:Authorization: DPoP {access_token}DPoP: {proof_jwt}

Header:

欄位說明
typdpop+jwtDPoP proof 的固定類型
algES256EdDSA簽名演算法
jwk{ ... }傳送方的 JWK 格式公鑰

Payload:

欄位必填說明
jti重播保護用的唯一識別符
htm請求的 HTTP 方法(例如 POST
htu請求的 HTTP URL(不含查詢字串和片段)
iat發行時間戳(Unix epoch 秒)
athaccess token 的 Base64url 編碼 SHA-256 雜湊值
nonce條件性伺服器提供的 nonce,收到 DPoP-Nonce header 後必須提供
參數
支援演算法EdDSAES256
Nonce 到期時間300 秒
JTI 到期時間300 秒
IAT 最大期限300 秒
時鐘偏差容忍60 秒(向未來)

當伺服器要求 nonce 時,遵循以下交換流程:

Rendering diagram...
  1. 傳送不含 nonce 欄位的 DPoP proof 請求。
  2. 伺服器回傳 HTTP 400,錯誤碼 use_dpop_nonceDPoP-Nonce 回應 header。
  3. DPoP-Nonce header 的值作為 nonce 欄位重新建構 DPoP proof JWT。
  4. 以更新後的 DPoP proof 重試請求。
狀態碼錯誤碼原因
400invalid_dpop_proofDPoP proof 結構、簽名或 ath 驗證失敗
400use_dpop_nonce伺服器要求 DPoP nonce — 請檢查 DPoP-Nonce 回應 header

這些端點無需身份驗證。它們提供探索元資料、協定交換和公開註冊服務。

方法端點服務
GET/v1/offers/:offerIdCredential Issuer
GET/.well-known/openid-credential-issuer/:tenantCredential Issuer
GET/.well-known/oauth-authorization-serverAuthorization Server
POST/v1/tokenAuthorization Server
POST/v1/nonceCredential Issuer
POST/v1/parAuthorization Server
GET/v1/authorizeAuthorization Server
POST/v1/authorize/submitAuthorization Server
GET/v1/verifier/request/:requestUriIdVerifier Service
POST/v1/verifier/presentationVerifier Service
GET/schemas/:type/:versionSchema Registry
POST/v1/auth/loginTrust Registry
GET/.well-known/did-configuration.json/:tenantTrust Registry

方法路徑驗證類型DPoP 何時必須服務
POST/v1/offersAPI KeyCredential Issuer
GET/v1/offers/:offerId公開Credential Issuer
POST/credentialBearer JWT 或 DPoP-boundIssuer 註冊在 HAIP / X.509 / ES256 路徑時必須;EdDSA / DID 路徑為選用Credential Issuer
GET/.well-known/openid-credential-issuer/:tenant公開Credential Issuer
GET/.well-known/oauth-authorization-server公開Authorization Server
POST/v1/token公開申請 DPoP-bound access token 時須附 DPoP proof(HAIP 路徑)Authorization Server
POST/v1/nonce公開Credential Issuer
POST/v1/par公開Authorization Server
GET/v1/authorize公開Authorization Server
POST/v1/authorize/submit公開Authorization Server
POST/v1/verifier/authorization-requestAPI KeyVerifier Service
GET/v1/verifier/result/:sessionIdAPI KeyVerifier Service
GET/v1/verifier/request/:requestUriId公開Verifier Service
POST/v1/verifier/presentation公開Verifier Service
GET/schemas/:type/:version公開Schema Registry
POST/v1/auth/login公開Trust Registry
POST/v1/didBearer JWTTrust Registry
POST/v1/did/importBearer JWTTrust Registry
GET/.well-known/did-configuration.json/:tenant公開Trust Registry

狀態碼錯誤說明
400invalid_grant預授權碼已過期或已使用
400invalid_dpop_proofDPoP proof 結構、簽名或 ath 驗證失敗
400use_dpop_nonce伺服器要求 DPoP nonce — 請檢查 DPoP-Nonce 回應 header
401invalid_tokenAccess token 無效或已過期
401invalid_token(DPoP 路徑)Token 結構有效,但端點要求 DPoP 綁定 —— issuer 註冊於 HAIP / X.509 / ES256 路徑。請改以 Authorization: DPoP <token> 加上 DPoP: proof header 重發(見 §3)。
401API Key is required缺少 X-API-Key header
401Invalid API KeyAPI 金鑰未找到或雜湊不符
401Account is not approvedAPI 金鑰有效但帳號等待核准中
403Forbidden帳號未取得此操作的授權