incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

如何创建用户以及设置密码对指定图有权限

Open ZQYKing opened this issue 6 months ago • 1 comments

Problem Type (问题类型)

None

Before submit

  • [x] 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • Server Version: 1.0.0 (Apache Release Version)
  • Backend: RocksDB x nodes, HDD or SSD
  • OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
  • Data Size: xx vertices, xx edges

Your Question (问题描述)

如何创建用户以及设置密码对指定图有权限

Vertex/Edge example (问题点 / 边数据举例)


Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)


ZQYKing avatar Jun 11 '25 01:06 ZQYKing

HugeGraph 支持通过 RESTful API 创建用户、设置密码,并为指定图分配权限。核心流程如下:

  1. 创建用户
    使用 POST /graphs/{graph}/auth/users,请求体为 JSON,例如:

    {
      "user_name": "newuser",
      "user_password": "yourpassword",
      "user_phone": "1234567890",
      "user_email": "[email protected]"
    }
    

    密码会自动加密存储。接口实现详见 UserAPI

  2. 修改用户密码
    使用 PUT /graphs/{graph}/auth/users/{id},请求体只需包含新密码字段:

    {
      "user_password": "newpassword"
    }
    

    详情见 UserAPI update 方法

  3. 分配权限
    需先创建用户组(group)和目标(target),然后通过 POST /graphs/{graph}/auth/accesses 分配权限,示例请求体:

    {
      "group": "groupId",
      "target": "targetId",
      "access_permission": "READ", // 或 WRITE、ADMIN 等
      "access_description": "描述"
    }
    

    权限类型由 HugePermission 枚举定义。接口实现见 AccessAPI

  4. 认证方式
    默认超级管理员为 admin,认证采用 HTTP Basic Auth,格式为 Authorization: Basic base64(admin:密码),如需示例可参考 相关 issue

如需更详细的 API 字段说明,可直接参考源码中的 JsonUserJsonAccess 类定义。实际操作建议用 Postman 或 curl 进行接口调用。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

dosubot[bot] avatar Jun 11 '25 01:06 dosubot[bot]

Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label

github-actions[bot] avatar Jun 26 '25 21:06 github-actions[bot]