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

   <!-- Answer -->
   在 HugeGraph 1.0.0 中,用户管理和权限分配主要通过 RESTful API 实现。核心流程如下:
   
   1. **创建用户**  
      通过 POST 请求 `/graphs/{graph}/auth/users`,提交 JSON 
格式的用户信息(如用户名、密码等),即可创建新用户。密码会自动加密存储。例如:
   
      ```http
      POST /graphs/{graph}/auth/users
      Content-Type: application/json
   
      {
        "user_name": "testuser",
        "user_password": "yourpassword"
      }
      ```
      详见 [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}`,body 结构与创建类似。
   
   3. **分配权限**  
      权限分配是通过“组-资源-权限”模型实现的。一般流程为:  
      - 创建用户后,将用户加入某个组(Group)。
      - 创建目标资源(Target),如指定的图。
      - 通过 POST `/graphs/{graph}/auth/accesses`,为组分配对目标资源的权限(如 READ、WRITE 
等)。body 示例:
   
        ```http
        POST /graphs/{graph}/auth/accesses
        Content-Type: application/json
   
        {
          "group": "group_id",
          "target": "target_id",
          "access_permission": "WRITE",
          "access_description": "write access to graph"
        }
        ```
      详见 [AccessAPI 
源码实现](https://github.com/apache/incubator-hugegraph/blob/337dc86567834acd717a2240a79fef2815d4bb6f/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/AccessAPI.java)。
   
   4. **权限类型**  
      权限类型包括:NONE、READ、WRITE、DELETE、EXECUTE、ANY,详见 [HugePermission 
枚举](https://github.com/apache/incubator-hugegraph/blob/337dc86567834acd717a2240a79fef2815d4bb6f/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/auth/HugePermission.java)。
   
   **注意事项**:  
   - 需要先启用 HugeGraph 的认证和权限功能(auth)。
   - 组和目标资源的创建、用户与组的关联等也有对应 API,具体可参考源码实现。
   - 默认超级管理员用户名为 `admin`,可用其进行初始操作。
   
   如需更详细的 API 使用示例或遇到具体报错,可以补充说明。
   
   
   <!-- 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/dce4f688-321d-4622-8b06-39f3c987e482?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/dce4f688-321d-4622-8b06-39f3c987e482?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/dce4f688-321d-4622-8b06-39f3c987e482?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/dce4f688-321d-4622-8b06-39f3c987e482?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/dce4f688-321d-4622-8b06-39f3c987e482?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/dce4f688-321d-4622-8b06-39f3c987e482?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/dce4f688-321d-4622-8b06-39f3c987e482?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/2795)


-- 
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