Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(wolf-rbac): change default port number and add authType parameter to documentation #5477

Merged
merged 2 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/plugins/wolf-rbac.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local schema = {
},
server = {
type = "string",
default = "http://127.0.0.1:10080"
default = "http://127.0.0.1:12180"
},
header_prefix = {
type = "string",
Expand Down
7 changes: 4 additions & 3 deletions docs/en/latest/plugins/wolf-rbac.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The rbac feature is provided by [wolf](https://github.com/iGeeky/wolf). For more

| Name | Type | Requirement | Default | Valid | Description |
| ------------- | ------ | ----------- | ------------------------ | ----- | --------------------------------------------------------- |
| server | string | optional | "http://127.0.0.1:10080" | | Set the service address of `wolf-server`. |
| server | string | optional | "http://127.0.0.1:12180" | | Set the service address of `wolf-server`. |
| appid | string | optional | "unset" | | Set the app id. The app id must be added in wolf-console. |
| header_prefix | string | optional | "X-" | | prefix of custom HTTP header. After authentication is successful, three headers will be added to the request header (for backend) and response header (for frontend): `X-UserId`, `X-Username`, `X-Nickname`. |

Expand Down Expand Up @@ -73,7 +73,7 @@ curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f
"username":"wolf_rbac",
"plugins":{
"wolf-rbac":{
"server":"http://127.0.0.1:10080",
"server":"http://127.0.0.1:12180",
"appid":"restful"
}
},
Expand Down Expand Up @@ -113,13 +113,14 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
#### Login and get `wolf-rbac` token:

The following `appid`, `username`, and `password` must be real ones in the wolf system.
`authType` is the authentication type, `1` is password authentication, `2` is `LDAP` authentication. The default is `1`. `wolf` supports `LDAP` authentication since version 0.5.0

* Login as `POST application/json`

```shell
curl http://127.0.0.1:9080/apisix/plugin/wolf-rbac/login -i \
-H "Content-Type: application/json" \
-d '{"appid": "restful", "username":"test", "password":"user-password"}'
-d '{"appid": "restful", "username":"test", "password":"user-password", "authType":1}'

HTTP/1.1 200 OK
Date: Wed, 24 Jul 2019 10:33:31 GMT
Expand Down
7 changes: 4 additions & 3 deletions docs/zh/latest/plugins/wolf-rbac.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rbac 功能由[wolf](https://github.com/iGeeky/wolf)提供, 有关 `wolf` 的更

| 名称 | 类型 | 必选项 | 默认值 | 有效值 | 描述 |
| ------------- | ------ | ------ | ------------------------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| server | string | 可选 | "http://127.0.0.1:10080" | | 设置 `wolf-server` 的访问地址 |
| server | string | 可选 | "http://127.0.0.1:12180" | | 设置 `wolf-server` 的访问地址 |
| appid | string | 可选 | "unset" | | 设置应用 id, 该应用 id, 需要是在 `wolf-console` 中已经添加的应用 id |
| header_prefix | string | 可选 | "X-" | | 自定义 http 头的前缀。`wolf-rbac`在鉴权成功后, 会在请求头(用于传给后端)及响应头(用于传给前端)中添加 3 个头: `X-UserId`, `X-Username`, `X-Nickname` |

Expand Down Expand Up @@ -73,7 +73,7 @@ curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f
"username":"wolf_rbac",
"plugins":{
"wolf-rbac":{
"server":"http://127.0.0.1:10080",
"server":"http://127.0.0.1:12180",
"appid":"restful"
}
},
Expand Down Expand Up @@ -113,13 +113,14 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
#### 首先进行登录获取 `wolf-rbac` token:

下面的 `appid`, `username`, `password` 必须为 wolf 系统中真实存在的.
`authType` 为认证类型, `1` 为密码认证, `2` 为 `LDAP` 认证. 默认为 `1`. `wolf` 从 0.5.0 版本开始支持了 `LDAP` 认证.

* 以 POST application/json 方式登陆.

```shell
curl http://127.0.0.1:9080/apisix/plugin/wolf-rbac/login -i \
-H "Content-Type: application/json" \
-d '{"appid": "restful", "username":"test", "password":"user-password"}'
-d '{"appid": "restful", "username":"test", "password":"user-password", "authType":1}'

HTTP/1.1 200 OK
Date: Wed, 24 Jul 2019 10:33:31 GMT
Expand Down
2 changes: 1 addition & 1 deletion t/plugin/wolf-rbac.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ __DATA__
--- request
GET /t
--- response_body_like eval
qr/\{"appid":"unset","header_prefix":"X-","server":"http:\/\/127\.0\.0\.1:10080"\}/
qr/\{"appid":"unset","header_prefix":"X-","server":"http:\/\/127\.0\.0\.1:12180"\}/
--- no_error_log
[error]

Expand Down