动态客户端注册
Dynamic Client Registration (DCR) 允许您的软件通过一次 HTTP 请求即可在 Casdoor 中注册 OAuth 客户端,而无需在管理员 UI 中手动创建应用。 这在向最终用户分发工具时很有帮助:MCP客户端、CLI或桌面应用可在首次运行或安装时获取客户端凭据。 Casdoor 实施了 RFC 7591。
注册端点
该端点在 OIDC 发现中公开。 请求 /.well-known/openid-configuration:
curl https://your-casdoor.com/.well-known/openid-configuration
使用 registration_endpoint 的值(例如 /api/oauth/register)进行注册:
{
"issuer": "https://your-casdoor.com",
"authorization_endpoint": "https://your-casdoor.com/login/oauth/authorize",
"token_endpoint": "https://your-casdoor.com/api/login/oauth/access_token",
"registration_endpoint": "https://your-casdoor.com/api/oauth/register",
...
}
注册客户端
使用 JSON 元数据向 /api/oauth/register 发送 POST 请求:
curl -X POST https://your-casdoor.com/api/oauth/register \
-H "Content-Type: application/json" \
-d '{
"client_name": "Claude Desktop",
"redirect_uris": ["http://localhost:3000/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "none",
"application_type": "native"
}'
响应包括新的客户端凭据:
{
"client_id": "a1b2c3d4e5f6",
"client_secret": "secret_xyz789...",
"client_id_issued_at": 1737799294,
"client_secret_expires_at": 0,
"redirect_uris": ["http://localhost:3000/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "none",
"application_type": "native"
}