blob: aa27cdf51e62d053c6c27a22c2f3c6b449d53d54 [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
169 in: path
170 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: '异常响应'
336 required:
337 - code
338 - message
339 properties:
340 code:
341 title: 异常代码
342 type: integer
343 format: int32
344 default: -1
345 message:
346 title: 异常信息
347 type: string
348 default: "未知错误"
349
350 # Entity
351
352 BaseEntity:
353 title: 实体 - 基类
354 type: object
355 properties:
356 id:
357 title: ID
358 type: string
359 #companyId:
360 # title: 'Company ID, 固定 1'
361 # type: string
362 # default: '1'
363 #deleted:
364 # title: 是否删除
365 # type: boolean
366 # default: false
367 #addAccount:
368 # title: 创建人
369 # type: string
370 #addTime:
371 # title: 创建时间
372 # type: string
373 # format: date-time
374 #editAccount:
375 # title: 修改人
376 # type: string
377 #editTime:
378 # title: 修改时间
379 # type: string
380 # format: date-time
381 #deleteAccount:
382 # title: 删除人
383 # type: string
384 #deleteTime:
385 # title: 删除时间
386 # type: string
387 # format: date-time
388
389 User:
390 title: 实体 - 用户
391 allOf:
392 - $ref: '#/components/schemas/BaseEntity'
393 - type: object
394 title: 实体属性
395 properties:
396 username:
397 title: 代码
398 type: string
399 name:
400 title: 姓名
401 type: string
402
403 Role:
404 title: 实体 - 角色
405 allOf:
406 - $ref: '#/components/schemas/BaseEntity'
407 - type: object
408 title: 实体属性
409 properties:
刘洪青bd15b942020-11-05 16:14:07 +0800410 applicationId:
411 title: 所属应用
412 type: string
刘洪青47205852020-08-14 13:39:30 +0800413 code:
414 title: 代码
415 type: string
416 name:
417 title: 名称
418 type: string
419 description:
420 title: 描述
421 type: string
422 enabled:
423 title: 是否可用
424 type: boolean
425 externalId:
426 title: 扩展ID
427 type: string
428
刘洪青bd15b942020-11-05 16:14:07 +0800429
430 GroupModel:
431 title: 模型 - 用户组
432 allOf:
433 - type: object
434 title: 实体属性
435 properties:
436 id:
437 title: ID
438 type: string
439 applicationId:
440 title: 所属应用
441 type: string
442 code:
443 title: 代码
444 type: string
445 name:
446 title: 名称
447 type: string
448 description:
449 title: 描述
450 type: string
451 type:
452 title: 类型,1 普通用户组,2 岗位用户组
453 type: string
454 state:
455 title: 状态,0:正常 1:冻结 2:注销
456 type: integer
457 format: int32
458 sort:
459 title: 排序
460 type: integer
461 format: int32
462 common:
463 title: 是否公共
464 type: boolean
465
刘洪青47205852020-08-14 13:39:30 +0800466 # Request VO
467
468
469 # Response Data
470
471
472 # Response VO
473
474 AbstractApiResponse:
475 title: 响应
476 properties:
477 acknowleged:
478 title: 响应结果(废弃,请使用code)
479 type: boolean
480 default: true
481 code:
482 title: 响应代码
483 type: integer
484 format: int32
485 default: 0
486 message:
487 title: 响应信息
488 type: string
489 DefaultApiResponse:
490 allOf:
491 - $ref: '#/components/schemas/AbstractApiResponse'
492 - type: object
493 title: 响应数据
494 properties:
495 data:
496 title: 响应数据
497 type: object
498
499
500
501 ApplicationRolesResponse:
502 allOf:
503 - $ref: '#/components/schemas/DefaultApiResponse'
504 - type: object
505 title: 响应数据
506 properties:
507 data:
508 allOf:
509 - type: object
510 title: 数据
511 properties:
512 applicationId:
513 title: 应用标识
514 type: string
515 roles:
516 title: 角色数据
517 type: array
518 items:
519 $ref: '#/components/schemas/Role'
520
521
522 ApplicationRoleAccountsResponse:
523 allOf:
524 - $ref: '#/components/schemas/DefaultApiResponse'
525 - type: object
526 title: 响应数据
527 properties:
528 data:
529 allOf:
530 - type: object
531 title: 数据
532 properties:
533 applicationId:
534 title: 应用标识
535 type: string
536 rolecode:
537 title: 角色代码
538 type: string
539 accounts:
540 title: 用户帐号数据
541 type: array
542 items:
543 title: 用户的帐号ID
544 type: string
545
546
547 AccountApplicationRolesResponse:
548 allOf:
549 - $ref: '#/components/schemas/DefaultApiResponse'
550 - type: object
551 title: 响应数据
552 properties:
553 data:
554 allOf:
555 - type: object
556 title: 数据
557 properties:
558 username:
559 title: 用户名
560 type: string
561 applicationId:
562 title: 应用标识
563 type: string
564 roles:
565 title: 角色数据
566 type: array
567 items:
568 $ref: '#/components/schemas/Role'
569
570
刘洪青bd15b942020-11-05 16:14:07 +0800571 ApplicationRoleGroupsResponse:
572 allOf:
573 - $ref: '#/components/schemas/DefaultApiResponse'
574 - type: object
575 title: 响应数据
576 properties:
577 data:
578 allOf:
579 - type: object
580 title: 数据
581 properties:
582 applicationId:
583 title: 应用标识
584 type: string
585 rolecode:
586 title: 角色代码
587 type: string
588 groupIds:
589 title: 用户组ID列表
590 type: array
591 items:
592 title: 用户组ID
593 type: string
594 groups:
595 title: 用户组列表
596 type: array
597 items:
598 $ref: '#/components/schemas/GroupModel'
599
刘洪青103e7242020-12-14 13:33:58 +0800600
601 ApplicationExternalRoleAccountsResponse:
602 allOf:
603 - $ref: '#/components/schemas/DefaultApiResponse'
604 - type: object
605 title: 响应数据
606 properties:
607 data:
608 allOf:
609 - type: object
610 title: 数据
611 properties:
612 applicationId:
613 title: 应用标识
614 type: string
615 externalId:
616 title: 应用内角色ID
617 type: string
618 accounts:
619 title: 用户帐号数据
620 type: array
621 items:
622 title: 用户的帐号ID
623 type: string
624
625 ApplicationExternalRolesAccountsResponse:
626 allOf:
627 - $ref: '#/components/schemas/DefaultApiResponse'
628 - type: object
629 title: 响应数据
630 properties:
631 data:
632 allOf:
633 - type: object
634 title: 数据
635 properties:
636 applicationId:
637 title: 应用标识
638 type: string
639 externalIds:
640 title: 应用内角色IDs
641 type: array
642 items:
643 title: 角色ID
644 type: string
645 accounts:
646 title: 用户帐号数据
647 type: array
648 items:
649 title: 用户的帐号ID
650 type: string