刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 1 | # user-authorization-service-poa.v1.yaml |
| 2 | # |
| 3 | # 1. 创建服务 |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 4 | # curl -i -s -X POST 'https://poa-sa.supwisdom.com/v1/services' -H 'Content-Type: application/json' -d '{"id": "authz", "origin": "http://user-authorization-poa-svc.user-authorization-service.svc.cluster.local:8080", "name": "授权服务", "description": "授权服务"}' |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 5 | # |
| 6 | # 2. 创建版本 |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 7 | # curl -i -s -X POST 'https://poa-sa.supwisdom.com/v1/services/authz/apiVersions/v1' |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 8 | # |
| 9 | # 3. 上传OAS Yaml |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 10 | # curl -i -s -X POST 'https://poa-sa.supwisdom.com/v1/services/authz/apiVersions/v1/apiSpecs' -H 'Content-Type: application/yaml' --data-binary @user-authorization-service-poa.v1.yaml |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 11 | # |
| 12 | # 4. 发布版本 |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 13 | # curl -i -s -X POST 'https://poa-sa.supwisdom.com/v1/services/authz/apiVersions/v1/publish' |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 14 | # |
| 15 | openapi: 3.0.2 |
| 16 | info: |
| 17 | title: User Authorization Service Platform Open APIs |
| 18 | version: v1 |
| 19 | description: '用户授权服务 - 平台开放接口' |
| 20 | servers: |
刘洪青 | 77c6774 | 2020-09-07 12:22:44 +0800 | [diff] [blame] | 21 | - url: '${POA_SERVER_URL}/apis/authz/v1' |
刘洪青 | 6b495a4 | 2020-11-16 16:28:40 +0800 | [diff] [blame] | 22 | description: '生产环境' |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 23 | tags: |
| 24 | - name: Role |
| 25 | description: '角色' |
| 26 | paths: |
| 27 | |
| 28 | '/application/{applicationId}/roles': |
| 29 | get: |
| 30 | summary: 获取应用下的角色列表 |
| 31 | description: 获取应用下的角色列表 |
| 32 | operationId: loadApplicationRoles |
| 33 | tags: |
| 34 | - Role |
| 35 | security: |
| 36 | - oauth2: |
| 37 | - "authz:v1:readRole" |
| 38 | parameters: |
| 39 | - name: applicationId |
| 40 | in: path |
| 41 | required: true |
| 42 | description: 应用标识 |
| 43 | schema: |
| 44 | type: string |
| 45 | responses: |
| 46 | '200': |
| 47 | description: 角色列表 |
| 48 | content: |
| 49 | application/json: |
| 50 | schema: |
| 51 | $ref: '#/components/schemas/ApplicationRolesResponse' |
| 52 | default: |
| 53 | $ref: '#/components/responses/DefaultErrorResponse' |
| 54 | |
| 55 | |
| 56 | '/application/{applicationId}/role/{rolecode}/accounts': |
| 57 | get: |
| 58 | summary: 获取应用下的一个角色的用户帐号 |
| 59 | description: 获取应用下的一个角色的用户帐号 |
| 60 | operationId: loadApplicationRoleAccounts |
| 61 | tags: |
| 62 | - Role |
| 63 | security: |
| 64 | - oauth2: |
| 65 | - "authz:v1:readRole" |
| 66 | parameters: |
| 67 | - name: applicationId |
| 68 | in: path |
| 69 | required: true |
| 70 | description: 应用标识 |
| 71 | schema: |
| 72 | type: string |
| 73 | - name: rolecode |
| 74 | in: path |
| 75 | required: true |
| 76 | description: 角色代码 |
| 77 | schema: |
| 78 | type: string |
| 79 | - name: loadAll |
| 80 | in: query |
| 81 | required: false |
| 82 | description: 分页-是否返回所有(当为 true 时,不分页,参数 pageIndex、pageSize 无效) |
| 83 | schema: |
| 84 | type: boolean |
| 85 | default: false |
| 86 | - name: pageIndex |
| 87 | in: query |
| 88 | required: false |
| 89 | description: 分页-页码 |
| 90 | schema: |
| 91 | type: integer |
| 92 | format: int32 |
| 93 | default: 0 |
| 94 | - name: pageSize |
| 95 | in: query |
| 96 | required: false |
| 97 | description: 分页-每页记录数 |
| 98 | schema: |
| 99 | type: integer |
| 100 | format: int32 |
| 101 | default: 1000 |
| 102 | responses: |
| 103 | '200': |
| 104 | description: 用户的帐号ID |
| 105 | content: |
| 106 | application/json: |
| 107 | schema: |
| 108 | $ref: '#/components/schemas/ApplicationRoleAccountsResponse' |
| 109 | default: |
| 110 | $ref: '#/components/responses/DefaultErrorResponse' |
| 111 | |
| 112 | '/application/{applicationId}/account/{username}/roles': |
| 113 | get: |
| 114 | summary: 获取用户帐号在某一应用下所拥有的角色 |
| 115 | description: 获取用户帐号在某一应用下所拥有的角色 |
| 116 | operationId: loadAccountApplicationRoles |
| 117 | tags: |
| 118 | - Role |
| 119 | security: |
| 120 | - oauth2: |
| 121 | - "authz:v1:readRole" |
| 122 | parameters: |
| 123 | - name: applicationId |
| 124 | in: path |
| 125 | required: true |
| 126 | description: 应用标识 |
| 127 | schema: |
| 128 | type: string |
| 129 | - name: username |
| 130 | in: path |
| 131 | required: true |
| 132 | description: 用户名 |
| 133 | schema: |
| 134 | type: string |
| 135 | responses: |
| 136 | '200': |
| 137 | description: 角色列表 |
| 138 | content: |
| 139 | application/json: |
| 140 | schema: |
| 141 | $ref: '#/components/schemas/AccountApplicationRolesResponse' |
| 142 | default: |
| 143 | $ref: '#/components/responses/DefaultErrorResponse' |
| 144 | |
| 145 | '/application/{applicationId}/roles/accounts': |
| 146 | post: |
| 147 | summary: 获取应用下的多个角色的用户帐号 |
| 148 | description: 获取应用下的多个角色的用户帐号 |
| 149 | operationId: loadAccountsByApplicationRole |
| 150 | tags: |
| 151 | - Role |
| 152 | security: |
| 153 | - oauth2: |
| 154 | - "authz:v1:readRole" |
| 155 | parameters: |
| 156 | - name: applicationId |
| 157 | in: path |
| 158 | required: true |
| 159 | description: 应用标识 |
| 160 | schema: |
| 161 | type: string |
| 162 | - name: loadAll |
| 163 | in: query |
| 164 | required: false |
| 165 | description: 分页-是否返回所有(当为 true 时,不分页,参数 pageIndex、pageSize 无效) |
| 166 | schema: |
| 167 | type: boolean |
| 168 | default: false |
| 169 | - name: pageIndex |
| 170 | in: query |
| 171 | required: false |
| 172 | description: 分页-页码 |
| 173 | schema: |
| 174 | type: integer |
| 175 | format: int32 |
| 176 | default: 0 |
| 177 | - name: pageSize |
| 178 | in: query |
| 179 | required: false |
| 180 | description: 分页-每页记录数 |
| 181 | schema: |
| 182 | type: integer |
| 183 | format: int32 |
| 184 | default: 1000 |
| 185 | requestBody: |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 186 | description: 角色ID |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 187 | required: true |
| 188 | content: |
| 189 | application/json: |
| 190 | schema: |
| 191 | type: array |
| 192 | items: |
| 193 | title: 角色ID |
| 194 | type: string |
| 195 | responses: |
| 196 | '200': |
| 197 | description: 用户的帐号ID |
| 198 | content: |
| 199 | application/json: |
| 200 | schema: |
| 201 | $ref: '#/components/schemas/ApplicationRolesAccountsResponse' |
| 202 | default: |
| 203 | $ref: '#/components/responses/DefaultErrorResponse' |
| 204 | |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 205 | |
| 206 | '/application/{applicationId}/role/{rolecode}/groups': |
| 207 | get: |
| 208 | summary: 获取应用下的一个角色关联的用户组 |
| 209 | description: 获取应用下的一个角色关联的用户组 |
| 210 | operationId: loadApplicationRoleGroups |
| 211 | tags: |
| 212 | - Role |
| 213 | security: |
| 214 | - oauth2: |
| 215 | - "authz:v1:readRole" |
| 216 | parameters: |
| 217 | - name: applicationId |
| 218 | in: path |
| 219 | required: true |
| 220 | description: 应用标识 |
| 221 | schema: |
| 222 | type: string |
| 223 | - name: rolecode |
| 224 | in: path |
| 225 | required: true |
| 226 | description: 角色代码 |
| 227 | schema: |
| 228 | type: string |
| 229 | - name: groupType |
| 230 | in: path |
| 231 | required: false |
| 232 | description: 用户组类型(1 普通,2 岗位) |
| 233 | schema: |
| 234 | type: string |
| 235 | responses: |
| 236 | '200': |
| 237 | description: 角色关联的用户组列表 |
| 238 | content: |
| 239 | application/json: |
| 240 | schema: |
| 241 | $ref: '#/components/schemas/ApplicationRoleGroupsResponse' |
| 242 | default: |
| 243 | $ref: '#/components/responses/DefaultErrorResponse' |
| 244 | |
| 245 | |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 246 | components: |
| 247 | |
| 248 | # Security Schemes |
| 249 | |
| 250 | securitySchemes: |
| 251 | oauth2: |
| 252 | type: oauth2 |
| 253 | flows: |
| 254 | clientCredentials: |
刘洪青 | 77c6774 | 2020-09-07 12:22:44 +0800 | [diff] [blame] | 255 | tokenUrl: ${POA_SERVER_URL}/oauth2/token |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 256 | scopes: |
| 257 | "authz:v1:readRole": "读取角色" |
| 258 | |
| 259 | responses: |
| 260 | 'ErrorResponse400': |
| 261 | description: unexpected error |
| 262 | content: |
| 263 | application/json: |
| 264 | schema: |
| 265 | $ref: '#/components/schemas/ErrorResponse' |
| 266 | |
| 267 | DefaultErrorResponse: |
| 268 | description: unexpected error |
| 269 | content: |
| 270 | application/json: |
| 271 | schema: |
| 272 | $ref: '#/components/schemas/ErrorResponse' |
| 273 | |
| 274 | schemas: |
| 275 | |
| 276 | # Error |
| 277 | |
| 278 | ErrorResponse: |
| 279 | title: '异常响应' |
| 280 | required: |
| 281 | - code |
| 282 | - message |
| 283 | properties: |
| 284 | code: |
| 285 | title: 异常代码 |
| 286 | type: integer |
| 287 | format: int32 |
| 288 | default: -1 |
| 289 | message: |
| 290 | title: 异常信息 |
| 291 | type: string |
| 292 | default: "未知错误" |
| 293 | |
| 294 | # Entity |
| 295 | |
| 296 | BaseEntity: |
| 297 | title: 实体 - 基类 |
| 298 | type: object |
| 299 | properties: |
| 300 | id: |
| 301 | title: ID |
| 302 | type: string |
| 303 | #companyId: |
| 304 | # title: 'Company ID, 固定 1' |
| 305 | # type: string |
| 306 | # default: '1' |
| 307 | #deleted: |
| 308 | # title: 是否删除 |
| 309 | # type: boolean |
| 310 | # default: false |
| 311 | #addAccount: |
| 312 | # title: 创建人 |
| 313 | # type: string |
| 314 | #addTime: |
| 315 | # title: 创建时间 |
| 316 | # type: string |
| 317 | # format: date-time |
| 318 | #editAccount: |
| 319 | # title: 修改人 |
| 320 | # type: string |
| 321 | #editTime: |
| 322 | # title: 修改时间 |
| 323 | # type: string |
| 324 | # format: date-time |
| 325 | #deleteAccount: |
| 326 | # title: 删除人 |
| 327 | # type: string |
| 328 | #deleteTime: |
| 329 | # title: 删除时间 |
| 330 | # type: string |
| 331 | # format: date-time |
| 332 | |
| 333 | User: |
| 334 | title: 实体 - 用户 |
| 335 | allOf: |
| 336 | - $ref: '#/components/schemas/BaseEntity' |
| 337 | - type: object |
| 338 | title: 实体属性 |
| 339 | properties: |
| 340 | username: |
| 341 | title: 代码 |
| 342 | type: string |
| 343 | name: |
| 344 | title: 姓名 |
| 345 | type: string |
| 346 | |
| 347 | Role: |
| 348 | title: 实体 - 角色 |
| 349 | allOf: |
| 350 | - $ref: '#/components/schemas/BaseEntity' |
| 351 | - type: object |
| 352 | title: 实体属性 |
| 353 | properties: |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 354 | applicationId: |
| 355 | title: 所属应用 |
| 356 | type: string |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 357 | code: |
| 358 | title: 代码 |
| 359 | type: string |
| 360 | name: |
| 361 | title: 名称 |
| 362 | type: string |
| 363 | description: |
| 364 | title: 描述 |
| 365 | type: string |
| 366 | enabled: |
| 367 | title: 是否可用 |
| 368 | type: boolean |
| 369 | externalId: |
| 370 | title: 扩展ID |
| 371 | type: string |
| 372 | |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 373 | |
| 374 | GroupModel: |
| 375 | title: 模型 - 用户组 |
| 376 | allOf: |
| 377 | - type: object |
| 378 | title: 实体属性 |
| 379 | properties: |
| 380 | id: |
| 381 | title: ID |
| 382 | type: string |
| 383 | applicationId: |
| 384 | title: 所属应用 |
| 385 | type: string |
| 386 | code: |
| 387 | title: 代码 |
| 388 | type: string |
| 389 | name: |
| 390 | title: 名称 |
| 391 | type: string |
| 392 | description: |
| 393 | title: 描述 |
| 394 | type: string |
| 395 | type: |
| 396 | title: 类型,1 普通用户组,2 岗位用户组 |
| 397 | type: string |
| 398 | state: |
| 399 | title: 状态,0:正常 1:冻结 2:注销 |
| 400 | type: integer |
| 401 | format: int32 |
| 402 | sort: |
| 403 | title: 排序 |
| 404 | type: integer |
| 405 | format: int32 |
| 406 | common: |
| 407 | title: 是否公共 |
| 408 | type: boolean |
| 409 | |
刘洪青 | 4720585 | 2020-08-14 13:39:30 +0800 | [diff] [blame] | 410 | # Request VO |
| 411 | |
| 412 | |
| 413 | # Response Data |
| 414 | |
| 415 | |
| 416 | # Response VO |
| 417 | |
| 418 | AbstractApiResponse: |
| 419 | title: 响应 |
| 420 | properties: |
| 421 | acknowleged: |
| 422 | title: 响应结果(废弃,请使用code) |
| 423 | type: boolean |
| 424 | default: true |
| 425 | code: |
| 426 | title: 响应代码 |
| 427 | type: integer |
| 428 | format: int32 |
| 429 | default: 0 |
| 430 | message: |
| 431 | title: 响应信息 |
| 432 | type: string |
| 433 | DefaultApiResponse: |
| 434 | allOf: |
| 435 | - $ref: '#/components/schemas/AbstractApiResponse' |
| 436 | - type: object |
| 437 | title: 响应数据 |
| 438 | properties: |
| 439 | data: |
| 440 | title: 响应数据 |
| 441 | type: object |
| 442 | |
| 443 | |
| 444 | |
| 445 | ApplicationRolesResponse: |
| 446 | allOf: |
| 447 | - $ref: '#/components/schemas/DefaultApiResponse' |
| 448 | - type: object |
| 449 | title: 响应数据 |
| 450 | properties: |
| 451 | data: |
| 452 | allOf: |
| 453 | - type: object |
| 454 | title: 数据 |
| 455 | properties: |
| 456 | applicationId: |
| 457 | title: 应用标识 |
| 458 | type: string |
| 459 | roles: |
| 460 | title: 角色数据 |
| 461 | type: array |
| 462 | items: |
| 463 | $ref: '#/components/schemas/Role' |
| 464 | |
| 465 | |
| 466 | ApplicationRoleAccountsResponse: |
| 467 | allOf: |
| 468 | - $ref: '#/components/schemas/DefaultApiResponse' |
| 469 | - type: object |
| 470 | title: 响应数据 |
| 471 | properties: |
| 472 | data: |
| 473 | allOf: |
| 474 | - type: object |
| 475 | title: 数据 |
| 476 | properties: |
| 477 | applicationId: |
| 478 | title: 应用标识 |
| 479 | type: string |
| 480 | rolecode: |
| 481 | title: 角色代码 |
| 482 | type: string |
| 483 | accounts: |
| 484 | title: 用户帐号数据 |
| 485 | type: array |
| 486 | items: |
| 487 | title: 用户的帐号ID |
| 488 | type: string |
| 489 | |
| 490 | |
| 491 | AccountApplicationRolesResponse: |
| 492 | allOf: |
| 493 | - $ref: '#/components/schemas/DefaultApiResponse' |
| 494 | - type: object |
| 495 | title: 响应数据 |
| 496 | properties: |
| 497 | data: |
| 498 | allOf: |
| 499 | - type: object |
| 500 | title: 数据 |
| 501 | properties: |
| 502 | username: |
| 503 | title: 用户名 |
| 504 | type: string |
| 505 | applicationId: |
| 506 | title: 应用标识 |
| 507 | type: string |
| 508 | roles: |
| 509 | title: 角色数据 |
| 510 | type: array |
| 511 | items: |
| 512 | $ref: '#/components/schemas/Role' |
| 513 | |
| 514 | |
| 515 | ApplicationRolesAccountsResponse: |
| 516 | allOf: |
| 517 | - $ref: '#/components/schemas/DefaultApiResponse' |
| 518 | - type: object |
| 519 | title: 响应数据 |
| 520 | properties: |
| 521 | data: |
| 522 | allOf: |
| 523 | - type: object |
| 524 | title: 数据 |
| 525 | properties: |
| 526 | applicationId: |
| 527 | title: 应用标识 |
| 528 | type: string |
| 529 | roleIds: |
| 530 | title: 角色IDs |
| 531 | type: array |
| 532 | items: |
| 533 | title: 角色ID |
| 534 | type: string |
| 535 | accounts: |
| 536 | title: 用户帐号数据 |
| 537 | type: array |
| 538 | items: |
| 539 | title: 用户的帐号ID |
| 540 | type: string |
刘洪青 | bd15b94 | 2020-11-05 16:14:07 +0800 | [diff] [blame] | 541 | |
| 542 | |
| 543 | ApplicationRoleGroupsResponse: |
| 544 | allOf: |
| 545 | - $ref: '#/components/schemas/DefaultApiResponse' |
| 546 | - type: object |
| 547 | title: 响应数据 |
| 548 | properties: |
| 549 | data: |
| 550 | allOf: |
| 551 | - type: object |
| 552 | title: 数据 |
| 553 | properties: |
| 554 | applicationId: |
| 555 | title: 应用标识 |
| 556 | type: string |
| 557 | rolecode: |
| 558 | title: 角色代码 |
| 559 | type: string |
| 560 | groupIds: |
| 561 | title: 用户组ID列表 |
| 562 | type: array |
| 563 | items: |
| 564 | title: 用户组ID |
| 565 | type: string |
| 566 | groups: |
| 567 | title: 用户组列表 |
| 568 | type: array |
| 569 | items: |
| 570 | $ref: '#/components/schemas/GroupModel' |
| 571 | |