Client Key
Client Key 是用來簽署 token 的密碼學金鑰對。公開金鑰會透過 JWKS 提供驗證,私鑰永不暴露。
Schema
interface ClientKey {
kid: string; // Key ID used in JWT headers
credential_id: string; // Client ID (cid...)
jwk: object; // Public JWK
public_key: string; // PEM public key
}
屬性
| 屬性 | 型別 | 說明 |
|---|---|---|
kid | string | 金鑰 ID(JWT header 的 kid) |
credential_id | string | 此金鑰所屬 client |
jwk | object | 公開 JWK 表示 |
public_key | string | PEM 公鑰 |
JWKS 表示
公開金鑰會出現在 /.well-known/jwks.json:
{
"keys": [
{
"kty": "RSA",
"use": "sig",
"kid": "key_2kHfPZcN9xW4mE8RtY7vB",
"alg": "RS256",
"n": "0vx7agoebG...",
"e": "AQAB"
}
]
}
金鑰輪替
最佳實務:
- 定期輪替金鑰
- 過渡期間保持 2-4 把有效金鑰
- 舊金鑰暫留 JWKS 供既有 token 驗證
範例
{
"kid": "key_2kHfPZcN9xW4mE8RtY7vB",
"credential_id": "cid_1jGePYbM8wV3lD7QsX6uA",
"jwk": { "kty": "RSA", "kid": "key_..." },
"public_key": "-----BEGIN PUBLIC KEY-----..."
}
相關
- Client - 用戶端設定
- 用戶端 - 用戶端管理
- Backend 整合 - Token 驗證