dosubot[bot] commented on issue #2793:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2793#issuecomment-2960924445

   <!-- Answer -->
   HugeGraph 支持通过 RESTful API 创建用户、设置密码,并为指定图分配权限。核心流程如下:
   
   1. **创建用户**  
      使用 `POST /graphs/{graph}/auth/users`,请求体为 JSON,例如:
      ```json
      {
        "user_name": "newuser",
        "user_password": "yourpassword",
        "user_phone": "1234567890",
        "user_email": "[email protected]"
      }
      ```
      密码会自动加密存储。接口实现详见 
[UserAPI](https://github.com/apache/incubator-hugegraph/blob/337dc86567834acd717a2240a79fef2815d4bb6f/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java)。
   
   2. **修改用户密码**  
      使用 `PUT /graphs/{graph}/auth/users/{id}`,请求体只需包含新密码字段:
      ```json
      {
        "user_password": "newpassword"
      }
      ```
      详情见 [UserAPI update 
方法](https://github.com/apache/incubator-hugegraph/blob/337dc86567834acd717a2240a79fef2815d4bb6f/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java)。
   
   3. **分配权限**  
      需先创建用户组(group)和目标(target),然后通过 `POST /graphs/{graph}/auth/accesses` 
分配权限,示例请求体:
      ```json
      {
        "group": "groupId",
        "target": "targetId",
        "access_permission": "READ", // 或 WRITE、ADMIN 等
        "access_description": "描述"
      }
      ```
      权限类型由 `HugePermission` 枚举定义。接口实现见 
[AccessAPI](https://github.com/apache/incubator-hugegraph/blob/337dc86567834acd717a2240a79fef2815d4bb6f/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java)。
   
   4. **认证方式**  
      默认超级管理员为 `admin`,认证采用 HTTP Basic Auth,格式为 `Authorization: Basic 
base64(admin:密码)`,如需示例可参考 [相关 
issue](https://github.com/apache/incubator-hugegraph/issues/2727)。
   
   如需更详细的 API 字段说明,可直接参考源码中的 `JsonUser` 和 `JsonAccess` 类定义。实际操作建议用 Postman 或 
curl 进行接口调用。
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/7248e725-9775-4033-85b6-3411562b2236?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[!
 [Share on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/issues/2793)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to