blob: 2f0af3de3a6df718fc5147625c464f9134aab569 [file] [log] [blame]
刘洪青47205852020-08-14 13:39:30 +08001# user-authorization-service-poa.v1.yaml
2#
3# 1. 创建服务
刘洪青bd15b942020-11-05 16:14:07 +08004# 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": "授权服务"}'
刘洪青47205852020-08-14 13:39:30 +08005#
6# 2. 创建版本
刘洪青bd15b942020-11-05 16:14:07 +08007# curl -i -s -X POST 'https://poa-sa.supwisdom.com/v1/services/authz/apiVersions/v1'
刘洪青47205852020-08-14 13:39:30 +08008#
9# 3. 上传OAS Yaml
刘洪青bd15b942020-11-05 16:14:07 +080010# 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
刘洪青47205852020-08-14 13:39:30 +080011#
12# 4. 发布版本
刘洪青bd15b942020-11-05 16:14:07 +080013# curl -i -s -X POST 'https://poa-sa.supwisdom.com/v1/services/authz/apiVersions/v1/publish'
刘洪青47205852020-08-14 13:39:30 +080014#
15openapi: 3.0.2
16info:
17 title: User Authorization Service Platform Open APIs
18 version: v1
19 description: '用户授权服务 - 平台开放接口'
20servers:
刘洪青77c67742020-09-07 12:22:44 +080021 - url: '${POA_SERVER_URL}/apis/authz/v1'
刘洪青6b495a42020-11-16 16:28:40 +080022 description: '生产环境'
刘洪青47205852020-08-14 13:39:30 +080023tags:
24 - name: Role
25 description: '角色'
26paths:
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
刘洪青bd15b942020-11-05 16:14:07 +0800145 '/application/{applicationId}/role/{rolecode}/groups':
146 get:
147 summary: 获取应用下的一个角色关联的用户组
148 description: 获取应用下的一个角色关联的用户组
149 operationId: loadApplicationRoleGroups
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: rolecode
163 in: path
164 required: true
165 description: 角色代码
166 schema:
167 type: string
168 - name: groupType
刘洪青f3b5fc82021-01-11 23:54:40 +0800169 in: query
刘洪青bd15b942020-11-05 16:14:07 +0800170 required: false
171 description: 用户组类型(1 普通,2 岗位)
172 schema:
173 type: string
174 responses:
175 '200':
176 description: 角色关联的用户组列表
177 content:
178 application/json:
179 schema:
180 $ref: '#/components/schemas/ApplicationRoleGroupsResponse'
181 default:
182 $ref: '#/components/responses/DefaultErrorResponse'
183
184
刘洪青103e7242020-12-14 13:33:58 +0800185 '/application/{applicationId}/externalRole/{externalId}/accounts':
186 get:
187 summary: 获取应用下的一个角色的用户帐号
188 description: 获取应用下的一个角色的用户帐号
189 operationId: loadAccountsByApplicationExternalRole
190 tags:
191 - Role
192 security:
193 - oauth2:
194 - "authz:v1:readRole"
195 parameters:
196 - name: applicationId
197 in: path
198 required: true
199 description: 应用标识
200 schema:
201 type: string
202 - name: externalId
203 in: path
204 required: true
205 description: 应用内角色ID
206 schema:
207 type: string
208 - name: loadAll
209 in: query
210 required: false
211 description: 分页-是否返回所有(当为 true 时,不分页,参数 pageIndex、pageSize 无效)
212 schema:
213 type: boolean
214 default: false
215 - name: pageIndex
216 in: query
217 required: false
218 description: 分页-页码
219 schema:
220 type: integer
221 format: int32
222 default: 0
223 - name: pageSize
224 in: query
225 required: false
226 description: 分页-每页记录数
227 schema:
228 type: integer
229 format: int32
230 default: 1000
231 responses:
232 '200':
233 description: 角色关联的帐号ID
234 content:
235 application/json:
236 schema:
237 $ref: '#/components/schemas/ApplicationExternalRoleAccountsResponse'
238 default:
239 $ref: '#/components/responses/DefaultErrorResponse'
240
241 '/application/{applicationId}/externalRoles/accounts':
242 post:
243 summary: 获取应用下的多个角色的用户帐号
244 description: 获取应用下的多个角色的用户帐号
245 operationId: loadAccountsByApplicationExternalRoles
246 tags:
247 - Role
248 security:
249 - oauth2:
250 - "authz:v1:readRole"
251 parameters:
252 - name: applicationId
253 in: path
254 required: true
255 description: 应用标识
256 schema:
257 type: string
258 - name: loadAll
259 in: query
260 required: false
261 description: 分页-是否返回所有(当为 true 时,不分页,参数 pageIndex、pageSize 无效)
262 schema:
263 type: boolean
264 default: false
265 - name: pageIndex
266 in: query
267 required: false
268 description: 分页-页码
269 schema:
270 type: integer
271 format: int32
272 default: 0
273 - name: pageSize
274 in: query
275 required: false
276 description: 分页-每页记录数
277 schema:
278 type: integer
279 format: int32
280 default: 1000
281 requestBody:
282 description: 应用内角色ID列表
283 required: true
284 content:
285 application/json:
286 schema:
287 type: array
288 items:
289 title: 应用内角色ID
290 type: string
291 responses:
292 '200':
293 description: 角色关联的帐号ID
294 content:
295 application/json:
296 schema:
297 $ref: '#/components/schemas/ApplicationExternalRolesAccountsResponse'
298 default:
299 $ref: '#/components/responses/DefaultErrorResponse'
300
301
刘洪青47205852020-08-14 13:39:30 +0800302components:
303
304 # Security Schemes
305
306 securitySchemes:
307 oauth2:
308 type: oauth2
309 flows:
310 clientCredentials:
刘洪青77c67742020-09-07 12:22:44 +0800311 tokenUrl: ${POA_SERVER_URL}/oauth2/token
刘洪青47205852020-08-14 13:39:30 +0800312 scopes:
313 "authz:v1:readRole": "读取角色"
314
315 responses:
316 'ErrorResponse400':
317 description: unexpected error
318 content:
319 application/json:
320 schema:
321 $ref: '#/components/schemas/ErrorResponse'
322
323 DefaultErrorResponse:
324 description: unexpected error
325 content:
326 application/json:
327 schema:
328 $ref: '#/components/schemas/ErrorResponse'
329
330 schemas:
331
332 # Error
333
334 ErrorResponse:
335 title: '异常响应'
刘洪青f3b5fc82021-01-11 23:54:40 +0800336 type: object
刘洪青47205852020-08-14 13:39:30 +0800337 required:
338 - code
339 - message
340 properties:
341 code:
342 title: 异常代码
343 type: integer
344 format: int32
345 default: -1
346 message:
347 title: 异常信息
348 type: string
349 default: "未知错误"
350
351 # Entity
352
353 BaseEntity:
354 title: 实体 - 基类
355 type: object
356 properties:
357 id:
358 title: ID
359 type: string
360 #companyId:
361 # title: 'Company ID, 固定 1'
362 # type: string
363 # default: '1'
364 #deleted:
365 # title: 是否删除
366 # type: boolean
367 # default: false
368 #addAccount:
369 # title: 创建人
370 # type: string
371 #addTime:
372 # title: 创建时间
373 # type: string
374 # format: date-time
375 #editAccount:
376 # title: 修改人
377 # type: string
378 #editTime:
379 # title: 修改时间
380 # type: string
381 # format: date-time
382 #deleteAccount:
383 # title: 删除人
384 # type: string
385 #deleteTime:
386 # title: 删除时间
387 # type: string
388 # format: date-time
389
390 User:
391 title: 实体 - 用户
392 allOf:
393 - $ref: '#/components/schemas/BaseEntity'
394 - type: object
395 title: 实体属性
396 properties:
397 username:
398 title: 代码
399 type: string
400 name:
401 title: 姓名
402 type: string
403
404 Role:
405 title: 实体 - 角色
406 allOf:
407 - $ref: '#/components/schemas/BaseEntity'
408 - type: object
409 title: 实体属性
410 properties:
刘洪青bd15b942020-11-05 16:14:07 +0800411 applicationId:
412 title: 所属应用
413 type: string
刘洪青47205852020-08-14 13:39:30 +0800414 code:
415 title: 代码
416 type: string
417 name:
418 title: 名称
419 type: string
420 description:
421 title: 描述
422 type: string
423 enabled:
424 title: 是否可用
425 type: boolean
426 externalId:
427 title: 扩展ID
428 type: string
429
刘洪青bd15b942020-11-05 16:14:07 +0800430
431 GroupModel:
432 title: 模型 - 用户组
433 allOf:
434 - type: object
435 title: 实体属性
436 properties:
437 id:
438 title: ID
439 type: string
440 applicationId:
441 title: 所属应用
442 type: string
443 code:
444 title: 代码
445 type: string
446 name:
447 title: 名称
448 type: string
449 description:
450 title: 描述
451 type: string
452 type:
453 title: 类型,1 普通用户组,2 岗位用户组
454 type: string
455 state:
456 title: 状态,0:正常 1:冻结 2:注销
457 type: integer
458 format: int32
459 sort:
460 title: 排序
461 type: integer
462 format: int32
463 common:
464 title: 是否公共
465 type: boolean
466
刘洪青47205852020-08-14 13:39:30 +0800467 # Request VO
468
469
470 # Response Data
471
472
473 # Response VO
474
475 AbstractApiResponse:
476 title: 响应
刘洪青f3b5fc82021-01-11 23:54:40 +0800477 type: object
刘洪青47205852020-08-14 13:39:30 +0800478 properties:
479 acknowleged:
480 title: 响应结果(废弃,请使用code)
481 type: boolean
482 default: true
483 code:
484 title: 响应代码
485 type: integer
486 format: int32
487 default: 0
488 message:
489 title: 响应信息
490 type: string
491 DefaultApiResponse:
492 allOf:
493 - $ref: '#/components/schemas/AbstractApiResponse'
494 - type: object
495 title: 响应数据
496 properties:
497 data:
498 title: 响应数据
499 type: object
500
501
502
503 ApplicationRolesResponse:
504 allOf:
505 - $ref: '#/components/schemas/DefaultApiResponse'
506 - type: object
507 title: 响应数据
508 properties:
509 data:
510 allOf:
511 - type: object
512 title: 数据
513 properties:
514 applicationId:
515 title: 应用标识
516 type: string
517 roles:
518 title: 角色数据
519 type: array
520 items:
521 $ref: '#/components/schemas/Role'
522
523
524 ApplicationRoleAccountsResponse:
525 allOf:
526 - $ref: '#/components/schemas/DefaultApiResponse'
527 - type: object
528 title: 响应数据
529 properties:
530 data:
531 allOf:
532 - type: object
533 title: 数据
534 properties:
535 applicationId:
536 title: 应用标识
537 type: string
538 rolecode:
539 title: 角色代码
540 type: string
541 accounts:
542 title: 用户帐号数据
543 type: array
544 items:
545 title: 用户的帐号ID
546 type: string
547
548
549 AccountApplicationRolesResponse:
550 allOf:
551 - $ref: '#/components/schemas/DefaultApiResponse'
552 - type: object
553 title: 响应数据
554 properties:
555 data:
556 allOf:
557 - type: object
558 title: 数据
559 properties:
560 username:
561 title: 用户名
562 type: string
563 applicationId:
564 title: 应用标识
565 type: string
566 roles:
567 title: 角色数据
568 type: array
569 items:
570 $ref: '#/components/schemas/Role'
571
572
刘洪青bd15b942020-11-05 16:14:07 +0800573 ApplicationRoleGroupsResponse:
574 allOf:
575 - $ref: '#/components/schemas/DefaultApiResponse'
576 - type: object
577 title: 响应数据
578 properties:
579 data:
580 allOf:
581 - type: object
582 title: 数据
583 properties:
584 applicationId:
585 title: 应用标识
586 type: string
587 rolecode:
588 title: 角色代码
589 type: string
590 groupIds:
591 title: 用户组ID列表
592 type: array
593 items:
594 title: 用户组ID
595 type: string
596 groups:
597 title: 用户组列表
598 type: array
599 items:
600 $ref: '#/components/schemas/GroupModel'
601
刘洪青103e7242020-12-14 13:33:58 +0800602
603 ApplicationExternalRoleAccountsResponse:
604 allOf:
605 - $ref: '#/components/schemas/DefaultApiResponse'
606 - type: object
607 title: 响应数据
608 properties:
609 data:
610 allOf:
611 - type: object
612 title: 数据
613 properties:
614 applicationId:
615 title: 应用标识
616 type: string
617 externalId:
618 title: 应用内角色ID
619 type: string
620 accounts:
621 title: 用户帐号数据
622 type: array
623 items:
624 title: 用户的帐号ID
625 type: string
626
627 ApplicationExternalRolesAccountsResponse:
628 allOf:
629 - $ref: '#/components/schemas/DefaultApiResponse'
630 - type: object
631 title: 响应数据
632 properties:
633 data:
634 allOf:
635 - type: object
636 title: 数据
637 properties:
638 applicationId:
639 title: 应用标识
640 type: string
641 externalIds:
642 title: 应用内角色IDs
643 type: array
644 items:
645 title: 角色ID
646 type: string
647 accounts:
648 title: 用户帐号数据
649 type: array
650 items:
651 title: 用户的帐号ID
652 type: string