chenhongzhou1 6fd7825d7f 资源列表搜索bug 4 роки тому
..
src 6fd7825d7f 资源列表搜索bug 4 роки тому
README.md 126c7b5e4b 添加springcloud 4 роки тому
mvnw 126c7b5e4b 添加springcloud 4 роки тому
mvnw.cmd 126c7b5e4b 添加springcloud 4 роки тому
pom.xml 16af403493 账户管理 4 роки тому

README.md

接口说明,支持两种方式,两套接口

1.使用JWT生成Token,使用shiro实现鉴权
2.使用oauth2结合shiro 实现鉴权

使用JWT生成Token,使用shiro实现鉴权

UMS返回参数说明

名称 类型 说明
type int 请求状态(0:失败;1:成功)
messageCode int 详情请移步错误码page
message String 提示信息
result Object 结果集

获取token

POST /shiro/auth/token
输入参数 必须 类型 中文描述
applicationKey yes String 需要登录的项目key
userName yes String 用户名
password yes String 密码
返回Result 类型 中文描述
token String 使用JWT生成的Token

请求示例

curl -X POST "http://localhost:8030/shiro/auth/token" -H "accept: */*" -H "Content-Type: application/json" -d "{ \"applicationKey\": \"urule\", \"password\": \"123456\", \"userName\": \"askerlve\"}"

返回示例

{
  "type": 1,
  "messageCode": 200,
  "message": "操作成功!",
  "result": {
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6InVydWxlIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJhc2tlcmx2ZSIsImV4cCI6MTUyNDYyNjQzMSwiaWF0IjoxNTI0NjI2MTMxfQ.q7HP26HAUVw7X7MF2Kjgqu49ky5DWJJAPR4xHAfuZ2Q"
  }
}

获取权限列表

GET /shiro/auth/list/permission
输入参数 必须 类型 中文描述
Authorization yes String 认证Token
返回Result 类型 中文描述
id int 资源id
parentId int 父节点id
applicationId int 所属系统id
name String 资源名称
code String 资源code
url String 资源地址
description String 资源描述
type int 资源类型(0:系统;1:菜单;2:API)
icon String 图标
order int 排序
status int 状态(0:禁用 1:启用 -3:垃圾桶 -4:删除)
createTime Date 创建时间
createUserId int 创建人id
updateTime Date 更新时间
updateUserId int 更新者id

请求示例

curl -X GET "http://localhost:8030/auth/list/permission" -H "accept: */*" -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6InVydWxlIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJhc2tlcmx2ZSIsImV4cCI6MTUyNDYyNjQzMSwiaWF0IjoxNTI0NjI2MTMxfQ.q7HP26HAUVw7X7MF2Kjgqu49ky5DWJJAPR4xHAfuZ2Q"

返回示例

{
  "type": 1,
  "messageCode": 200,
  "message": "操作成功!",
  "result": [
    {
      "id": 1,
      "parentId": null,
      "applicationId": 1,
      "name": "决策系统",
      "code": "DSQ",
      "url": "/urule",
      "description": "决策系统",
      "type": 0,
      "icon": null,
      "order": 2,
      "status": null,
      "createTime": "2018-04-20 17:14:34",
      "createUserId": 1,
      "updateTime": "2018-04-20 17:14:34",
      "updateUserId": 1
    },
    {
      "id": 4,
      "parentId": null,
      "applicationId": 1,
      "name": "用户管理",
      "code": "userManager",
      "url": "/urule/user",
      "description": "决策系统用户管理",
      "type": 1,
      "icon": null,
      "order": 0,
      "status": null,
      "createTime": "2018-04-24 18:39:51",
      "createUserId": 1,
      "updateTime": "2018-04-24 18:39:51",
      "updateUserId": 1
    }
  ]
}

判断当前用户是否有权限

POST /shiro/auth/judge/permission
输入参数 必须 类型 中文描述
applicationKey yes String 需要登录的项目key
Authorization yes String 认证Token
urlAddress yes String 需要鉴权的地址
返回Result 类型 中文描述
isAllowed boolean true:有权限;false:无权限

请求示例

curl -X POST "http://localhost:8030/auth/judge/permission" -H "accept: */*" -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6InVydWxlIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJhc2tlcmx2ZSIsImV4cCI6MTUyNDYzOTMzNSwiaWF0IjoxNTI0NjM5MDM1fQ.zA2J0GvIQGGp4tszhf515u-pFYRDwuU8zXuGK9AGo6I" -H "Content-Type: application/json" -d "{ \"urlAddress\": \"/urule\"}"

返回示例

{
  "type": 1,
  "messageCode": 200,
  "message": "操作成功!",
  "result": {
    "isAllowed": true
  }
}

使用oauth2 apache java实现结合shiro实现鉴权

1 授权码模式 将server端和client分别 运行后,在浏览输入 http://localhost:9080/oauth2-client/ http://localhost:8088/authorize?client_id=f3ed0d90-3fc8-4eba-b83c-a0cfe54c174d&response_type=code&redirect_uri=http://localhost:8091/oauth2-client/oauth2-login post client_secret=78e238b4-c199-49ad-b619-69b6a78959d8 grant_type=client_credentials

2 密码模式(Resource Owner Password Credentials Grant) 3 refresh_token 刷新access_token 4 客户端模式(Client Credentials Grant) http://localhost:8088/accessToken?client_id=f3ed0d90-3fc8-4eba-b83c-a0cfe54c174d&response_type=code&redirect_uri=http://localhost:8091/oauth2-client/oauth2-login http://localhost:8030/shiro2/oauth/accessToken?client_id=f3ed0d90-3fc8-4eba-b83c-a0cfe54c174d&response_type=access_token&redirect_uri=http://localhost:8083/hello post client_secret=78e238b4-c199-49ad-b619-69b6a78959d8 grant_type=client_credentials 5 简化模式(implicit grant type)