Contents

January 8, 2023 · View on GitHub

中文

Contents

Protocol

  • The Wolf interface uses Restful + JSON to communicate.
  • POST, PUT, DELETE requests all use Request Body to pass parameters, all in JSON format.
  • Content-Type for both request and response is application/json.
  • The body of the response contains a unified structure, which is later documented and no longer lists the entire structure, only the reason and data parts.

Example of a common structure of a response body:

{"ok": true, "reason": "error code or message", "errmsg": "error message", data: {When successful, the data returned}}

Generic field description of response

FieldTypeRequiredDescription
okbooleanYesService Status
reasonstringNoWhen ok=false, reason is the error code.
errmsgstringNoWhen ok=false, errmsg is the error message prompt.
dataobjectNoWhen ok=true, data is the returned information.

The system contains the following generic error codes(reason):

  • ERR_ARGS_ERROR Request parameter error, response code is 400
  • ERR_TOKEN_INVALID TOKEN invalid or missing, response code is 401
  • ERR_ACCESS_DENIED No authority to perform operations, response code 401
  • ERR_DUPLICATE_KEY_ERROR duplicated when updating data, response code 400
  • ERR_SERVER_ERROR Server internal error, response code 500

Models

UserModels

UserInfo

FieldTypeRequiredDescription
idintegerYesUser ID
usernamestringYesUser name
nicknamestringYesUser nickname
emailstringNoUser email
appIDsstring[]NoList of appIDs associated with users
managerstringYesadmin role, super: super admin, admin: general admin
createTimeintegerYescreate time

SimpleUserInfo

FieldTypeRequiredDescription
idintegerYesUser ID
usernamestringYesUser name
nicknamestringYesUser nickname

ApplicationModels

SimpleApplication

FieldTypeRequiredDescription
idstringYesApplication ID
namestringYesApplication name
descriptionstringNoDescription
createTimeintegerYesCreate time

Application

FieldTypeRequiredDescription
idstringYesApplication ID
namestringYesApplication name
descriptionstringNoDescription
secretstringNoSecret of application, used for OAuth2 login
redirectUrisstring[]Noredirect urls after successful OAuth2 login
accessTokenLifetimeintegerNoOAuth2's AccessToken life time, in seconds.
refreshTokenLifetimeintegerNoOAuth2's RefreshToken life time, in seconds.
createTimeintegerYesCreate time
updateTimeintegerYesUpdate time

RoleModels

Role

FieldTypeRequiredDescription
idstringYesRole ID
appIDstringYesApplication ID
namestringYesRole name
descriptionstringNoRole description
permIDsstring[]NoList of permissions held by the role
createTimeintegerYesCreate time

PermissionModels

Permission

FieldTypeRequiredDescription
idstringYesPermission ID
appIDstringYesApplication ID
namestringYesPermission name
descriptionstringNoPermission description
categoryIDintegerNoCategory ID of the permission
createTimeintegerYesCreate time

CategoryModels

Category

FieldTypeRequiredDescription
idstringYesCategory ID
appIDstringYesApplication ID
namestringYesCategory name
createTimeintegerYesCreate name

ResourceModels

Resource

FieldTypeRequiredDescription
idstringYesResource ID
appIDstringYesApplication ID
matchTypestringYesResource match type, equal: equal match, suffix: suffix match, prefix: prefix match.
namestringYesResource name, when matchType is equal, name is URL, when matchType is suffix, name is suffix value, when matchType is prefix, name is prefix of URL.
actionstringYesThe action/operation of the resource, usually the HTTP request method. The following values are available: ALL, GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH. where ALL indicates that all HTTP methods can be matched.
priorityintegerYesResource priorities.
permIDstringYespermission required to access the resource
createTimeintegerYesCreate time

AccessLogModels

AccessLog

FieldTypeRequiredDescription
idintegerYesLog ID
appIDstringYesApplication ID
userIDstringYesOperating user ID
usernamestringYesOperating user name
nicknamestringYesOperating user nickname
actionstringYesOperations performed (HTTP request method)
resNamestringYesURL to access
statusintegerYesresponse status code
datestringYesDate of access, formatted as yyyy-mm-dd
accessTimeintegerYesAccess time, unix timestamp
ipstringYesIP of the visitor

Login

The Console login interface is available only to users with administrator roles of super and admin.

Most interfaces in the administration backend require a Token, which is obtained after login with the administrator account. For interfaces that require a token, the token can be passed through the request header x-rbac-token.

The default token expiration time is 30 days. This can be changed via the environment variable CONSOLE_TOKEN_EXPIRE_TIME, in seconds. After modification, you need to restart Wolf-Server.

Method: POST

URL: /wolf/user/login

Request Body parameters

FieldTypeRequiredDescription
usernamestringYesUser name
passwordstringYesPassword
authTypeintegerNoAuthentication type, 1: Password, 2: LDAP

Response Body

  • data:
FieldTypeRequiredDescription
tokenstringYesUser login token
userInfoUserInfoYesLogin User Information
applicationsSimpleApplication[]YesUser's application list.
  • reason:
    • ERR_USER_NOT_FOUND: User do not exist
    • ERR_PASSWORD_ERROR: Password error
    • ERR_USER_DISABLED: User are disabled.
    • ERR_ACCESS_DENIED: Non-administrative users cannot login.
    • ERR_LDAP_CONFIG_NOT_FOUND: The server is not configured with LDAP when login with LDAP.

example

  • Request
curl http://127.0.0.1:12180/wolf/user/login \
-H "Content-Type: application/json" \
-d '{ "username": "root", "password": "password"}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "token": "WOLF-TOKEN-ENCODE-BY-JWT",
    "userInfo": {
      "id": 1,
      "username": "root",
      "nickname": "root(super man)",
      "email": null,
      "appIDs": [
        "openresty"
      ],
      "manager": "super",
      "createTime": 1580486400
    },
    "applications": [
      {
        "id": "restful",
        "name": "restful app",
        "description": "restful",
        "createTime": 1580486400
      }
    ]
  }
}

To facilitate the execution of the later example, save the token above as a variable in the shell environment:

export WOLF_TOKEN="WOLF-TOKEN-ENCODE-BY-JWT"

API-Application

Add Application

Add a new application

Method: POST

URL: /wolf/application

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idstringYesApplication ID, must be unique
namestringYesApplication name, must be unique
descriptionstringNoApplication description
secretstringNoSecret of application, used for OAuth2 login
redirectUrisstring[]Noredirect urls after successful OAuth2 login
accessTokenLifetimeintegerNoOAuth2's AccessToken life time in seconds, if it is 0, use the system default: 7 days.
refreshTokenLifetimeintegerNoOAuth2's RefreshToken life time, in seconds, if it is 0, use the system default: 30 days.

Response Body

  • data:
FieldTypeRequiredDescription
applicationApplicationYesNewly added application information

example

  • Request
curl http://127.0.0.1:12180/wolf/application \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "id": "test-app", "name": "application for test", "description": "description of application",
    "secret": "d41d8cd98f00b204e9800998ecf8427e",
    "redirectUris": ["http://127.0.0.1:12180/callback"],
    "accessTokenLifetime": 604801,
    "refreshTokenLifetime": 2592001
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "application": {
      "id": "test-app",
      "name": "application for test",
      "description": "description of application",
      "redirectUris": [
        "http://127.0.0.1:12180/callback"
      ],
      "grants": null,
      "accessTokenLifetime": 604801,
      "refreshTokenLifetime": 2592001,
      "createTime": 1580486400,
      "updateTime": 1580486400
    }
  }
}

Modify application

Modify application information

Method: PUT

URL: /wolf/application

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idstringYesApplication ID, must be unique, application ID cannot be modified.
namestringYesApplication name, must be unique
descriptionstringNoApplication description
secretstringNoSecret of application, used for OAuth2 login
redirectUrisstring[]Noredirect urls after successful OAuth2 login
accessTokenLifetimeintegerNoOAuth2's AccessToken life time in seconds, if it is 0, use the system default: 7 days.
refreshTokenLifetimeintegerNoOAuth2's RefreshToken life time, in seconds, if it is 0, use the system default: 30 days.

Response Body

  • data:
FieldTypeRequiredDescription
applicationApplicationYesModified application information

example

  • Request
curl http://127.0.0.1:12180/wolf/application \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": "test-app", "name": "test-application", "description": "description of application",
    "secret": "d41d8cd98f00b204e9800998ecf8427e",
    "redirectUris": ["http://127.0.0.1:12180/callback2"],
    "accessTokenLifetime": 604802,
    "refreshTokenLifetime": 2592002
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "application": {
      "id": "test-app",
      "name": "test-application",
      "description": "description of application",
      "redirectUris": [
        "http://127.0.0.1:12180/callback2"
      ],
      "grants": null,
      "accessTokenLifetime": 604802,
      "refreshTokenLifetime": 2592002,
      "createTime": 1580486400,
      "updateTime": 1580486401
    }
  }
}

Query a single application

Query a single application infomation

Method: GET

URL: /wolf/application/get

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
idstringYesApplication ID to query

Response Body

  • data:
FieldTypeRequiredDescription
applicationApplicationYesApplication information queried
  • reason:
    • ERR_OBJECT_NOT_FOUND The application ID of the query does not exist.

example

  • Request
curl "http://127.0.0.1:12180/wolf/application/get?id=test-app" \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "application": {
      "id": "test-app",
      "name": "test-application",
      "description": "description of application",
      "redirectUris": [
        "http://127.0.0.1:12180/callback2"
      ],
      "grants": null,
      "accessTokenLifetime": 604802,
      "refreshTokenLifetime": 2592002,
      "createTime": 1580486400,
      "updateTime": 1580486401
    }
  }
}

Query the application Secret

Query the Secret of an application.

Method: GET

URL: /wolf/application/secret

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
idstringYesApplication ID to query

Response Body

  • data:
FieldTypeRequiredDescription
secretstringYesSecret of application
  • reason:
    • ERR_OBJECT_NOT_FOUND The application ID of the query does not exist.

example

  • Request
curl "http://127.0.0.1:12180/wolf/application/secret?id=test-app" \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "secret": "d41d8cd98f00b204e9800998ecf8427e"
  }
}

Application List Query

Query the application list information.

Method: GET

URL: /wolf/application/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
keystringNoMatching by ID or name
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
applicationsApplication[]Yesapplication list.
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/application/list \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "applications": [
     {
        "id": "restful",
        "name": "restful app",
        "description": "restful",
        "redirectUris": [
          "http://localhost:12180/wolf/oauth2/client_app"
        ],
        "grants": null,
        "accessTokenLifetime": 3600,
        "refreshTokenLifetime": 2592000,
        "createTime": 1578817535,
        "updateTime": 1587375156
      },
      ...
    ],
    "total": 6
  }
}

List of all applications

Search all applications, no pagination.

Method: GET

URL: /wolf/application/list_all

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

None

Response Body

  • data:
FieldTypeRequiredDescription
applicationsApplication[]Yesall application list.
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/application/list_all \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "applications": [
     {
        "id": "restful",
        "name": "restful app",
        "description": "restful",
        "redirectUris": [
          "http://localhost:12180/wolf/oauth2/client_app"
        ],
        "grants": null,
        "accessTokenLifetime": 3600,
        "refreshTokenLifetime": 2592000,
        "createTime": 1578817535,
        "updateTime": 1587375156
      },
      ...
    ],
    "total": 6
  }
}

Delete application

Delete an application

Method: DELETE

URL: /wolf/application

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idstringYesApplication ID to be deleted

Response Body

  • data:
FieldTypeRequiredDescription
countintegerYesNumber of deletions, usually 1.
  • reason:
    • ERR_OBJECT_NOT_FOUND The application to be deleted does not exist.

example

  • Request
curl http://127.0.0.1:12180/wolf/application \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "id": "test-app"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-User

Add User

Add a new user

Method: POST

URL: /wolf/user

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
usernamestringYesUser name, to be used when loginto the system, must be composed of `letter + number + underscore' and must be unique.
nicknamestringYesUser nickname
passwordstringNoThe user password, if empty, will be generated by the service with a random value.
emailstringNoUser's email.(not used)
telstringNoThe user's mobile phone number.
appIDsstring[]NoA list of privileged appIDs managed by the user.
managerstringNoAdministrative permission, super: super administrator, with all permissions, admin: with basic administrative permissions (cannot add, modify, delete interfaces to applications and users).
statusintegerNoUser status, 0: normal status, -1: disabled status.

Response Body

  • data:
FieldTypeRequiredDescription
userInfoUserInfoYesNewly added user information
passwordstringYesPassword for newly added users

example

  • Request
curl http://127.0.0.1:12180/wolf/user \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "username": "test-user",
    "nickname": "user for test",
    "password": "abc#123",
    "email": "test-user@test.com",
    "tel": "123456",
    "appIDs": ["restful"],
    "manager": "none",
    "status": 0
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "password": "abc#123",
    "userInfo": {
      "id": 1024,
      "username": "test-user",
      "nickname": "user for test",
      "email": "test-user@test.com",
      "appIDs": [
        "restful"
      ],
      "manager": "none",
      "createTime": 1588576578
    }
  }

Modify user

Modify user information

Method: PUT

URL: /wolf/user

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idintegerYesUser ID, User ID to be modified
usernamestringYesUser name, to be used when loginto the system, must be composed of `letter + number + underscore' and must be unique.
nicknamestringYesUser nickname
emailstringNoUser's email.(not used)
telstringNoThe user's mobile phone number.
appIDsstring[]NoA list of privileged appIDs managed by the user.
managerstringNoAdministrative permission, super: super administrator, with all permissions, admin: with basic administrative permissions (cannot add, modify, delete interfaces to applications and users).
statusintegerNoUser status, 0: normal status, -1: disabled status.

Response Body

  • data:
FieldTypeRequiredDescription
userInfoUserInfoYesModified user information
  • reason:
    • ERR_USER_NOT_FOUND The user ID to be modified does not exist.

example

  • Request
curl http://127.0.0.1:12180/wolf/user \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": 1024,
    "username": "test-user",
    "nickname": "nickname for test",
    "email": "test-user@test.com",
    "tel": "123456",
    "appIDs": ["restful"],
    "manager": "none",
    "status": 0
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "effects": 1,
    "userInfo": {
      "id": 1024,
      "username": "test-user",
      "nickname": "nickname for test",
      "email": "test-user@test.com",
      "appIDs": [
        "restful"
      ],
      "manager": "none",
      "createTime": 1588576578
    }
  }
}

Check current user information

Query the user information of the specified token.

Method: GET

URL: /wolf/user/info

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

None

Response Body

  • data:
FieldTypeRequiredDescription
userInfoUserInfoYesModified user information
applicationsSimpleApplication[]NoUser Associated Applications List.

example

  • Request
curl "http://127.0.0.1:12180/wolf/user/info" \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response

  "ok": true,
  "reason": "",
  "data": {
    "userInfo": {
      "id": 696,
      "username": "root",
      "nickname": "root(super man)",
      "email": null,
      "appIDs": [
        "openresty"
      ],
      "manager": "super",
      "createTime": 1578401859
    },
    "applications": [
      {
        "id": "restful",
        "name": "restful app",
        "description": "restful",
        "createTime": 1578817535
      },
      ...
    ]
  }
}

User list query

Query the user list information

Method: GET

URL: /wolf/user/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
keystringNoSearch for username,nickname,tel field.
usernamestringNoUse username for exact user matching.
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
userInfosUserInfo[]Yesuser list
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/user/list \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "userInfos": [
     {
        "id": 697,
        "username": "admin",
        "nickname": "administrator",
        "email": null,
        "appIDs": [
          "openresty",
          "restful"
        ],
        "manager": "admin",
        "createTime": 1578401859
      },
      ...
    ],
    "total": 6
  }
}

Reset user password

Reset the user's password

Method: PUT

URL: /wolf/user/reset_pwd

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idintegerYesUser ID to reset password

Response Body

  • data:
FieldTypeRequiredDescription
passwordstringYesPassword to reset.
  • reason:
    • ERR_USER_NOT_FOUND The user to be deleted does not exist.
    • ERR_ACCESS_DENIED Only a super administrator can do this.

example

  • Request
curl http://127.0.0.1:12180/wolf/user/reset_pwd \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": 696
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "password": "197TLR0dPVdm"
  }
}

Delete user

Delete an user

Method: DELETE

URL: /wolf/user

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idintegerYesUser ID to be deleted

Response Body

  • data:
FieldTypeRequiredDescription
userInfoUserInfoYesDeleted user information
countintegerYesNumber of deletions, usually 1.
  • reason:
    • ERR_USER_NOT_FOUND The user to be deleted does not exist.
    • ERR_PERMISSION_DENY Can't delete super account
    • ERR_ACCESS_DENIED Only a super administrator can do this.

example

  • Request
curl http://127.0.0.1:12180/wolf/user \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "id": 2756
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-Role

Add Role

Add a new role

Method: POST

URL: /wolf/role

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID, the role can only belong to a certain application.
idstringYesRole ID, must be unique within the application
namestringYesRole name, must be unique within the application
descriptionstringNoRole description
permIDsstring[]NoA list of permission IDs for the role.

Response Body

  • data:
FieldTypeRequiredDescription
roleRoleYesNewly added role information

example

  • Request
curl http://127.0.0.1:12180/wolf/role \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "id": "test-role",
    "appID": "restful",
    "name": "role for test",
    "description": "description of role",
    "permIDs": ["PERM_XXX"]
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "role": {
      "id": "test-role",
      "appID": "restful",
      "name": "role for test",
      "description": "description of role",
      "permIDs": [
        "PERM_XXX"
      ],
      "createTime": 1588583707
    }
  }
}

Modify Role

Modify a role

Method: PUT

URL: /wolf/role

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID, cannot be modified
idstringYesRole ID, cannot be modified
namestringYesRole name, must be unique within the application
descriptionstringNoRole Description.
permIDsstring[]NoA list of permission IDs for the role.

Response Body

  • data:
FieldTypeRequiredDescription
roleRoleYesModified role information

example

  • Request
curl http://127.0.0.1:12180/wolf/role \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": "test-role",
    "appID": "restful",
    "name": "role for test",
    "description": "description of role",
    "permIDs": ["PERM_YYY"]
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "role": {
      "id": "test-role",
      "appID": "restful",
      "name": "role for test",
      "description": "description of role",
      "permIDs": [
        "PERM_YYY"
      ],
      "createTime": 1588583707
    }
  }
}

Adding permissions to role

Adding permissions to roles. Unlike the PUT method, this method only adds new permissions. The existing permissions remain unchanged.

Method: PATCH

URL: /wolf/role

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID, the role can only belong to a certain application.
idstringYesRole ID, must be unique within the application
permIDsstring[]YesList of permission IDs to add to the role.

Response Body

  • data:
FieldTypeRequiredDescription
roleRoleYesModified role information

example

  • Request
curl http://127.0.0.1:12180/wolf/role \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": "test-role",
    "appID": "restful",
    "name": "role for test",
    "description": "description of role",
    "permIDs": ["PERM_YYY"]
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "role": {
      "id": "test-role",
      "appID": "restful",
      "name": "role for test",
      "description": "description of role",
      "permIDs": [
        "PERM_XXX", "PERM_YYY"
      ],
      "createTime": 1588583707
    }
  }
}

Role list query

Query Role List Information

Method: GET

URL: /wolf/role/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
keystringNoMatching queries by ID or name
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
rolesRole[]YesRole list
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/role/list?appID=restful \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "roles": [
      {
        "id": "test-role",
        "name": "role for test",
        "description": "description of role",
        "appID": "restful",
        "permIDs": [
          "PERM_YYY"
        ],
        "createTime": 1588583707,
        "updateTime": 1588586200
      },
      ...
    ],
    "total": 5
  }
}

Delete Role

Delete a role

Method: DELETE

URL: /wolf/role

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
idstringYesRole ID to be deleted

Response Body

  • data:
FieldTypeRequiredDescription
countintegerYesNumber of deletions, usually 1.

example

  • Request
curl http://127.0.0.1:12180/wolf/role \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "id": "test-role",
    "appID": "restful"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-Permission

Add Permission

Add a new permission

Method: POST

URL: /wolf/permission

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID, permissions can only belong to a single application.
idstringYesPermission ID, must be unique within the application
namestringYesPermission name, must be unique within the application
descriptionstringNoDescription of permissions
categoryIDintegerNoPermissions correspond to category IDs

Response Body

  • data:
FieldTypeRequiredDescription
permissionPermissionYesNew permission information added

example

  • Request
curl http://127.0.0.1:12180/wolf/permission \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "id": "test-permission",
    "appID": "restful",
    "name": "permission for test",
    "description": "description of permission",
    "categoryID": 1
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "permission": {
      "id": "test-permission",
      "appID": "restful",
      "name": "permission for test",
      "description": "description of permission",
      "categoryID": 1,
      "createTime": 1588658062
    }
  }
}

Modify permissions

Modify permission information

Method: PUT

URL: /wolf/permission

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID, cannot be modified
idstringYesPermission ID, cannot be modified
namestringYesPermission name, must be unique within the application
descriptionstringNoDescription of permissions
categoryIDintegerNoPermissions correspond to category IDs

Response Body

  • data:
FieldTypeRequiredDescription
permissionPermissionYesModified permission information

example

  • Request
curl http://127.0.0.1:12180/wolf/permission \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": "test-permission",
    "appID": "restful",
    "name": "permission for test2",
    "description": "description of permission2",
    "categoryID": 2
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "permission": {
      "id": "test-permission",
      "appID": "restful",
      "name": "permission for test2",
      "description": "description of permission2",
      "createTime": 1588658062
    }
  }
}

Permission list query

Query list of permission information

Method: GET

URL: /wolf/permission/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
keystringNoMatching queries by ID or name
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
permissionsPermission[]YesList of permissions
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/permission/list?appID=restful \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response

  "ok": true,
  "reason": "",
  "data": {
    "permissions": [
      {
        "id": "test-permission",
        "appID": "restful",
        "name": "permission for test2",
        "description": "description of permission2",
        "categoryID": 2,
        "createTime": 1588658062,
        "updateTime": 1588658246,
        "category_id": 2,
        "category": null
      },
      ...
    ],
    "total": 2
  }
}

Delete Permission

Delete a permission

Method: DELETE

URL: /wolf/permission

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
idstringYesPermission ID to be removed

Response Body

  • data:
FieldTypeRequiredDescription
countintegerYesNumber of deletions, usually 1.
  • reason
    • ERR_ACCESS_DENIED The permission to delete is being used, and cannot be deleted.

example

  • Request
curl http://127.0.0.1:12180/wolf/permission \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "id": "test-permission",
    "appID": "restful"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-User-Role

User role related operations can only work on one application. So the related interfaces need to pass userID and appID parameters.

Get User Roles

Get user roles and permissions

Method: GET

URL: /wolf/user-role

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
userIDintegerYesUserID for which roles and permissions need to be get
appIDstringYesApplicationID for which roles and permissions need to be get

example

  • Request
curl "http://127.0.0.1:12180/wolf/user-role?userID=1&appID=restful" \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "userRole": {
      "userID": 1,
      "appID": "restful",
      "permIDs": [
        "RESTFUL_INDEX"
      ],
      "roleIDs": [
        "application"
      ],
      "createTime": 1609055508
    }
  }
}

Set User Roles

Set user roles or permissions

Method: POST

URL: /wolf/user-role/set

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
userIDintegerYesUserID for which roles or permissions need to be set
appIDstringYesApplicationID for which roles and permissions need to be set
permIDsstring[]YesList of permission IDs to be set
roleIDsstring[]YesList of role IDs to be set

example

  • Request
curl http://127.0.0.1:12180/wolf/user-role/set \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "userID": 1,
    "appID": "restful",
    "permIDs": ["RESTFUL_INDEX"],
    "roleIDs": ["application"]
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "userRole": {
      "userID": 1,
      "appID": "restful",
      "permIDs": [
        "RESTFUL_INDEX"
      ],
      "roleIDs": [
        "application"
      ],
      "createTime": 1609054766
    }
  }
}

Clear User Roles

Clear user roles and permissions

Method: DELETE

URL: /wolf/user-role

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
userIDintegerYesUserID for which roles or permissions need to be clear
appIDstringYesApplicationID for which roles and permissions need to be clear

example

  • Request
curl http://127.0.0.1:12180/wolf/user-role \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "userID": 1,
    "appID": "restful"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-Category

Add Category

Add a new category

Method: POST

URL: /wolf/category

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication IDs, categories can only belong to a single application.
namestringYesCategory name, must be unique within the application

Response Body

  • data:
FieldTypeRequiredDescription
categoryCategoryYesNewly added categories

example

  • Request
curl http://127.0.0.1:12180/wolf/category \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "appID": "restful",
    "name": "category for test"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "category": {
      "id": 744,
      "appID": "restful",
      "name": "category for test",
      "createTime": 1588659229
    }
  }
}

Modify Category

Modify a category

Method: PUT

URL: /wolf/category

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idintegerYesCategory ID, not modifiable
namestringYesCategory name, must be unique within the application

Response Body

  • data:
FieldTypeRequiredDescription
categoryCategoryYesModified categories

example

  • Request
curl http://127.0.0.1:12180/wolf/category \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
    "id": 744,
    "name": "category for test2"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "category": {
      "id": 744,
      "appID": "restful",
      "name": "category for test2",
      "createTime": 1588659229
    }
  }
}

Category List Query

Query list of category infomation

Method: GET

URL: /wolf/category/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
keystringNoSearch by name
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
categorysCategory[]YesList of categories
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/category/list?appID=restful \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "categorys": [
      {
        "id": 744,
        "appID": "restful",
        "name": "category for test2",
        "createTime": 1588659229,
        "updateTime": 1588659461
      }
    ],
    "total": 1
  }
}

Delete Category

Delete a category

Method: DELETE

URL: /wolf/category

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idstringYesCategory ID to be deleted

Response Body

  • data:
FieldTypeRequiredDescription
countintegerYesNumber of deletions, usually 1.

example

  • Request
curl http://127.0.0.1:12180/wolf/category \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "id": 744
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-Resource

Add Resources

Add a new resource

Method: POST

URL: /wolf/resource

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID, resources can only belong to one application.
matchTypestringYesResource matching type, equal: equals match, suffix: Suffix Match, prefix: Prefix Match.
namestringYesresource name, When matchType is equal, name is the URL, When matchType is suffix, name is suffix, When matchType is prefix, name is the URL prefix
actionstringNoThe action on the resource, usually HTTP Method. The following values are available: ALL, GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH. where ALL means that all HTTP methods can be matched.
permIDstringNoPermissions required to access the resource

Response Body

  • data:
FieldTypeRequiredDescription
resourceResourceYesNewly added resource information

example

  • Request
curl http://127.0.0.1:12180/wolf/resource \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-d '{
    "appID": "restful",
    "matchType": "equal",
    "name": "/path/to/resource",
    "action": "GET",
    "permID": "PERM_XXX"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "resource": {
      "id": 8512,
      "appID": "restful",
      "matchType": "equal",
      "name": "/path/to/resource",
      "priority": 10483,
      "action": "GET",
      "permID": "PERM_XXX",
      "createTime": 1588660594
    }
  }
}

Modify Resource

Modifying a resource

Method: PUT

URL: /wolf/resource

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idstringYesResource ID, cannot be modified
matchTypestringYesResource matching type, equal: equals match, suffix: Suffix Match, prefix: Prefix Match.
namestringYesresource name, When matchType is equal, name is the URL, When matchType is suffix, name is suffix, When matchType is prefix, name is the URL prefix
actionstringNoThe action on the resource, usually HTTP Method. The following values are available: ALL, GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH. where ALL means that all HTTP methods can be matched.
permIDstringNoPermissions required to access the resource

Response Body

  • data:
FieldTypeRequiredDescription
resourceResourceYesModified resource information

example

  • Request
curl http://127.0.0.1:12180/wolf/resource \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X PUT \
-d '{
   "id": 8512,
    "matchType": "equal",
    "name": "/path/to/resource",
    "action": "ALL",
    "permID": "PERM_YYY"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "resource": {
      "id": 8512,
      "appID": "restful",
      "matchType": "equal",
      "name": "/path/to/resource",
      "priority": 11483,
      "action": "ALL",
      "permID": "PERM_YYY",
      "createTime": 1588660594
    }
  }
}

Query Resource List

Query list of resources

Method: GET

URL: /wolf/resource/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
keystringNoMatch queries by resource name or permission
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
resourcesResource[]YesResource list
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/resource/list?appID=restful \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "resources": [
      {
        "id": 8512,
        "appID": "restful",
        "matchType": "equal",
        "name": "/path/to/resource",
        "priority": 11483,
        "action": "ALL",
        "permID": "PERM_YYY",
        "createTime": 1588660594
      },
      ...
    ],
    "total": 3
  }
}

Delete Resource

Delete a resource

Method: DELETE

URL: /wolf/resource

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Request Body parameters

FieldTypeRequiredDescription
idintegerYesResource ID to be deleted

Response Body

  • data:
FieldTypeRequiredDescription
countintegerYesNumber of deletions, usually 1.

example

  • Request
curl http://127.0.0.1:12180/wolf/resource \
-H "Content-Type: application/json" \
-H "x-rbac-token: $WOLF_TOKEN" \
-X DELETE \
-d '{
    "id": 8512
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "count": 1
  }
}

API-AccessLog

Access log list queries

Query list of access log information

Method: GET

URL: /wolf/access-log/list

Header parameters: Requires a token of Console login, passed through the x-rbac-token request header.

Query parameters

FieldTypeRequiredDescription
appIDstringYesApplication ID
usernamestringNoSearch by username or user nickname
actionstringNoresource action
resNamestringNoresource name
ipstringNoThe IP of the user operating the resource
statusintegerNoHTTP status code
startTimeintegerNoOperate time - start time
endTimeintegerNoOperate time - end time
sortstringNoSort field, e.g.: -id: means sort by id descending order. +name: Indicates ascending order by name.
pageintegerNoPage number, incremental from 1, default is 1
limitintegerNoPage size, default is 10

Response Body

  • data:
FieldTypeRequiredDescription
accessLogsAccessLog[]YesAccess Log List.
totalintegerYesTotal number of records

example

  • Request
curl http://127.0.0.1:12180/wolf/access-log/list?appID=restful \
-H "x-rbac-token: $WOLF_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "accessLogs": [
      {
        "id": 27999,
        "appID": "restful",
        "userID": "749",
        "username": "test",
        "nickname": "test",
        "action": "GET",
        "resName": "/",
        "matchedResource": {},
        "status": 401,
        "body": {},
        "contentType": null,
        "date": "2020-02-27",
        "accessTime": 1582816829,
        "ip": "127.0.0.1"
      },
      ...
    ],
    "total": 5
  }
}

API-RBAC

All interfaces starting with /wolf/rbac, are provided to Wolf's Agent It is called by the module. It is mainly used for the login and authentication processing of three-party applications.

Rbac-Login-Page

Agentlogin page

Method: GET

URL: /wolf/rbac/login

Query parameters

FieldTypeRequiredDescription
appidstringNoThe application ID to log in, if you don't have parameters, you can enter in the page
return_tostringNoSet the address to jump to after successful login. The default is /.

Response

Login page HTML.

example

  • Request
http://127.0.0.1:12180/wolf/rbac/login?return_to=%2Fwolf%2Foauth2%2Flogin_status&appid=restful
  • Response Page
Login Page
Login Page

RBAC-Restful-Login

Rbac login interface

Method: POST

URL: /wolf/rbac/login.rest

Request Body parameters

FieldTypeRequiredDescription
appidstringYesApplication ID
usernamestringYesLogin User Name
passwordstringYeslogin password
authTypeintegerNoAuthentication type, 1: Password, 2: LDAP

Response Body

  • data:
FieldTypeRequiredDescription
userInfoSimpleUserInfoYesBasic User Information
tokenstringYesLogin token
  • reason
    • ERR_USERNAME_MISSING username is missing.
    • ERR_PASSWORD_MISSING password is missng.
    • ERR_APPID_MISSING appid is missing.
    • ERR_USER_NOT_FOUND User do not exist
    • ERR_PASSWORD_ERROR Password error
    • ERR_USER_DISABLED User are disabled.
    • ERR_LDAP_CONFIG_NOT_FOUND The server is not configured with LDAP when login with LDAP.

example

  • Request
curl http://127.0.0.1:12180/wolf/rbac/login.rest \
-H "Content-Type: application/json" \
-X POST \
-d '{
    "username": "root",
    "password": "123456",
    "appid": "restful"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "userInfo": {
      "id": 696,
      "username": "root",
      "nickname": "root(super man)"
    },
    "token": "RBAC_TOKEN"
  }

The above token can be saved as a variable in the shell for the rest of the example:

export RBAC_TOKEN="WOLF-RBAC-TOKEN-ENCODE-BY-JWT"

The default token expiration time is 30 days. This can be changed via the environment variable RBAC_TOKEN_EXPIRE_TIME, in seconds. After modification, you need to restart Wolf-Server.

RBAC page login submission

Method: POST

URL: /wolf/rbac/login.submit

Content-Type: application/x-www-form-urlencoded

Request Body parameters

FieldTypeRequiredDescription
appidstringYesApplication ID
usernamestringYesLogin User Name
passwordstringYesLogin Password
return_tostringNoSet the address to jump to after successful login. The default is /.

Response

  • When Fails:

Redirect to the login page using 302.

  • When Success:

Use 302 to redirect to the page specified by return_to. And set the token to a cookie with key x-rbac-token.

example

  • Request
curl 'http://127.0.0.1:12180/wolf/rbac/login.submit' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'return_to=%2F&appid=restful&username=root&password=123456'
  • Response
< HTTP/1.1 302 Found
< Vary: Origin
< Access-Control-Allow-Origin: *
< Set-Cookie: x-rbac-token=RBAC-TOKEN; path=/; expires=Tue, 09 Jun 2020 08:47:21 GMT
< Location: /
< Content-Type: text/html; charset=utf-8
< Content-Length: 33

Query RBAC User Information

Query current logged in user information

Method: GET

URL: /wolf/rbac/user_info

Query parameters

None

Response

FieldTypeRequiredDescription
userInfoUserInfoYesuser information

example

  • Request
curl http://127.0.0.1:12180/wolf/rbac/user_info \
-H "Cookie: x-rbac-token=$RBAC_TOKEN"
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "userInfo": {
      "id": 696,
      "username": "root",
      "nickname": "root(super man)",
      "email": null,
      "appIDs": [
        "openresty"
      ],
      "manager": "super",
      "lastLogin": 1589100441,
      "profile": null,
      "createTime": 1578401859,
      "permissions": {},
      "roles": {}
    }
  }
}

logout

Method: POST

URL: /wolf/rbac/logout

Query parameters

None

Response

After the operation, the server will set the x-rbac-token in the cookie to logouted. and redirected 302 to the login page.

example

  • Request
curl http://127.0.0.1:12180/wolf/rbac/logout \
-H "Cookie: x-rbac-token=$RBAC_TOKEN"
  • Response
< HTTP/1.1 302 Found
< x-rbac-userID: 696
< x-rbac-username: root
< Set-Cookie: x-rbac-token=logouted; path=/; expires=Tue, 09 Jun 2020 09:04:56 GMT
< Location: /wolf/rbac/login.html?appid=restful
< Content-Type: text/html; charset=utf-8
< Content-Length: 101

Change Password

Method: POST

URL: /wolf/rbac/change_pwd

Request Body parameters

FieldTypeRequiredDescription
oldPasswordstringYesold password
newPasswordstringYesnew password

Response Body

  • data:

None

  • reason
    • ERR_PASSWORD_CHANGE_NOT_ALLOWED The server does not allow password changes.
    • ERR_OLD_PASSWORD_REQUIRED Missing old password
    • ERR_NEW_PASSWORD_REQUIRED Missing new password
    • TOKEN_USER_NOT_FOUND User do not exist
    • ERR_OLD_PASSWORD_INCORRECT Old Password error

example

  • Request
curl http://127.0.0.1:12180/wolf/rbac/change_pwd \
-H "Cookie: x-rbac-token=$RBAC_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d '{
    "oldPassword": "old-password",
    "newPassword": "new-password"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {}
}

Permission Checking Interface

Check if the user has access to the specified resource (appid + action + resName).

Method: POST

URL: /wolf/rbac/access_check

Request Body parameters

FieldTypeRequiredDescription
actionstringYesAction, usually is HTTP Method.
resNamestringYesThe name of the resource, usually URL Path or a resource extension.

The appid doesn't need to be passed, the service gets it directly from the token.

Response Body

If you have permission, the server returns the 200 status code, ok=true in json, and the user's information. If you don't have permission, the server returns the 401 status code, ok=false in the json, and the user's information.

  • data:
FieldTypeRequiredDescription
userInfoUserInfoYesCurrent User Information
  • reason If you don't have permission, the corresponding message will be displayed.

example

  • Request
curl http://127.0.0.1:12180/wolf/rbac/access_check \
-H "Cookie: x-rbac-token=$RBAC_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d '{
    "action": "GET",
    "resName": "/"
}'
  • Response
{
  "ok": true,
  "reason": "",
  "data": {
    "userInfo": {
      "id": 696,
      "username": "root",
      "nickname": "root(super man)",
      "email": null,
      "appIDs": [
        "openresty"
      ],
      "manager": "super",
      "lastLogin": 1589100441,
      "profile": null,
      "createTime": 1578401859,
      "permissions": {},
      "roles": {}
    }
  }
}

Back to TOC