2.2. 使用 Red Hat Quay API 创建用户帐户
使用 API 为您的 Red Hat Quay 存储库创建新用户。
先决条件
- 以超级用户身份登录 Red Hat Quay 部署。
- 您已创建了 OAuth 访问令牌。
-
您已在
config.yaml
文件中设置了BROWSER_API_CALLS_XHR_ONLY: false
。
流程
输入以下命令使用
POST /api/v1/superuser/users/
端点来创建新用户:$ curl -X POST -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{ "username": "newuser", "email": "newuser@example.com" }' "https://<quay-server.example.com>/api/v1/superuser/users/"
输出示例
{"username": "newuser", "email": "newuser@example.com", "password": "IJWZ8TIY301KPFOW3WEUJEVZ3JR11CY1", "encrypted_password": "9Q36xF54YEOLjetayC0NBaIKgcFFmIHsS3xTZDLzZSrhTBkxUc9FDwUKfnxLWhco6oBJV1NDBjoBcDGmsZMYPt1dSA4yWpPe/JKY9pnDcsw="}
导航到您的 Red Hat Quay registry 端点,如
quay-server.example.com
,并使用从 API 调用生成的用户名和密码登录。在这种情况下,用户名是newuser
,密码是IJWZ8TIY301KPFOW3WEUJEVZ3JR11CY1
。或者,您可以使用 CLI 登录 registry。例如:$ podman login <quay-server.example.com>
输出示例
username: newuser password: IJWZ8TIY301KPFOW3WEUJEVZ3JR11CY1
可选。您可以使用
GET /api/v1/superuser/users/
端点获取所有用户(包括超级用户)的列表:$ curl -X GET -H "Authorization: Bearer <bearer_token>" "https://<quay-server.example.com>/api/v1/superuser/users/"
输出示例
{"users": [{"kind": "user", "name": "quayadmin", "username": "quayadmin", "email": "quay@quay.com", "verified": true, "avatar": {"name": "quayadmin", "hash": "b28d563a6dc76b4431fc7b0524bbff6b810387dac86d9303874871839859c7cc", "color": "#17becf", "kind": "user"}, "super_user": true, "enabled": true}, {"kind": "user", "name": "newuser", "username": "newuser", "email": "newuser@example.com", "verified": true, "avatar": {"name": "newuser", "hash": "f338a2c83bfdde84abe2d3348994d70c34185a234cfbf32f9e323e3578e7e771", "color": "#9edae5", "kind": "user"}, "super_user": false, "enabled": true}]}