dosubot[bot] commented on issue #2794: URL: https://github.com/apache/incubator-hugegraph/issues/2794#issuecomment-2960923168
<!-- Answer --> HugeGraph 支持通过 RESTful API 创建用户、设置密码并分配图的权限。你可以用默认的 `admin` 用户(初始密码通常在配置或部署文档中,或首次启动时设置)进行管理操作。认证时需用 HTTP Basic Auth,格式为 `Authorization: Basic base64(admin:密码)`,如需生成 base64 可用 `echo -n 'admin:密码' | base64` 得到["相关讨论"](https://github.com/apache/incubator-hugegraph/issues/2727)。 1. **创建用户** 向 `POST /graphs/{graph}/auth/users` 发送 JSON,例如: ```json { "user_name": "testuser", "user_password": "yourpassword" } ``` 这样会在指定图下创建用户。 2. **修改用户密码等信息** 用 `PUT /graphs/{graph}/auth/users/{id}`,body 里填新密码等字段。 3. **分配权限** 用户权限通过角色和访问控制分配,相关 API 主要在 `/auth/groups`、`/auth/accesses` 等路径。你可以先创建用户组、目标资源,再用 `/auth/accesses` 关联用户组和资源,分配如读写等权限。权限类型见 HugePermission 枚举(如 READ、WRITE、DELETE 等)["API 参考"](https://github.com/apache/incubator-hugegraph/blob/337dc86567834acd717a2240a79fef2815d4bb6f/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/UserAPI.java)。 4. **登录获取 Token(可选)** 也可以用 `POST /graphs/{graph}/auth/login`,body 里填用户名和密码,返回 token 后用 Bearer 认证。 RocksDB 作为后端只负责数据存储,不影响用户和权限管理逻辑。 如需详细 API 参数和权限分配流程,可参考源码 UserAPI、StandardAuthManager 相关实现。 <!-- 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/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0cad5265-2aeb-4fbd-b56a-6a7d22b5b951?feedback_type=other)</sup> [](https://go.dosu.dev/discord-bot) [! [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/2794) -- 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]
