1
0

api-definition subdirectories rbac+test

This commit is contained in:
Michael Hoennig
2022-09-02 13:11:15 +02:00
parent 3541b0c48c
commit cd9be1db75
38 changed files with 373 additions and 329 deletions

View File

@ -8,41 +8,6 @@ servers:
paths:
# RBAC
/api/rbac/users:
$ref: "./api-definition/rbac-users.yaml"
/api/rbac/users/{userUuid}/permissions:
$ref: "./api-definition/rbac-users-with-id-permissions.yaml"
/api/rbac/users/{userUuid}:
$ref: "./api-definition/rbac-users-with-uuid.yaml"
/api/rbac/roles:
$ref: "./api-definition/rbac-roles.yaml"
/api/rbac/grants:
$ref: "./api-definition/rbac-grants.yaml"
/api/rbac/grants/{grantedRoleUuid}/{granteeUserUuid}:
$ref: "./api-definition/rbac-grants-with-id.yaml"
# Test-Entities for RBAC
/api/test/customers:
$ref: "./api-definition/test-customers.yaml"
/api/test/packages:
$ref: "./api-definition/test-packages.yaml"
/api/test/packages/{packageUUID}:
$ref: "./api-definition/test-packages-uuid.yaml"
# Other
/api/ping:
get:
tags:

View File

@ -1,5 +0,0 @@
The symbolik self-link 'api-definition' is a workaround to align IntelliJ IDEAs relative link interpretation with the interpretation of OpenAPI-generator.
Where IDEA only uses the path of the file in which the `$ref` is used,
the OpenAPI-generator always uses the path of the root API definition to resolve relative links.
See also https://github.com/OpenAPITools/openapi-generator/issues/10320.

View File

@ -1,43 +0,0 @@
get:
tags:
- rbacgrants
operationId: listUserGrants
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
post:
tags:
- rbacgrants
operationId: grantRoleToUser
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
requestBody:
required: true
content:
application/json:
schema:
$ref: './api-definition/rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
responses:
"201":
description: OK
content:
'application/json':
schema:
$ref: './api-definition/rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
"409":
$ref: './api-definition/error-responses.yaml#/components/responses/Conflict'

View File

@ -1,16 +0,0 @@
get:
tags:
- rbacroles
operationId: listRoles
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './api-definition/rbac-role-schemas.yaml#/components/schemas/RbacRole'

View File

@ -1,51 +0,0 @@
get:
tags:
- rbacusers
description: 'Fetch a single user by its id, if visible for the current subject.'
operationId: getUserById
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- name: userUuid
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './api-definition/rbac-user-schemas.yaml#/components/schemas/RbacUser'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
delete:
tags:
- rbacusers
operationId: deleteUserByUuid
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- name: userUuid
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the user to delete.
responses:
"204":
description: No Content
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
"404":
$ref: './api-definition/error-responses.yaml#/components/responses/NotFound'

View File

@ -1,48 +0,0 @@
get:
tags:
- rbacusers
description: List accessible RBAC users with optional filter by name.
operationId: listUsers
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- name: name
in: query
required: false
schema:
type: string
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './api-definition/rbac-user-schemas.yaml#/components/schemas/RbacUser'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
post:
tags:
- rbacusers
description: Create a new RBAC user.
operationId: createUser
requestBody:
required: true
content:
application/json:
schema:
$ref: './api-definition/rbac-user-schemas.yaml#/components/schemas/RbacUser'
responses:
"201":
description: Created
content:
'application/json':
schema:
$ref: './api-definition/rbac-user-schemas.yaml#/components/schemas/RbacUser'
"409":
$ref: './api-definition/error-responses.yaml#/components/responses/Conflict'

View File

@ -0,0 +1,12 @@
openapi-processor-mapping: v2
options:
package-name: net.hostsharing.hsadminng.rbac.generated.api.v1
model-name-suffix: Resource
map:
result: org.springframework.http.ResponseEntity
types:
- type: array => java.util.List
- type: string:uuid => java.util.UUID

View File

@ -0,0 +1 @@
../auth.yaml

View File

@ -0,0 +1 @@
../error-responses.yaml

View File

@ -1,10 +1,10 @@
get:
tags:
- rbacgrants
- rbac-grants
operationId: getGrantById
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: grantedRoleUuid
in: path
required: true
@ -25,21 +25,21 @@ get:
content:
'application/json':
schema:
$ref: './api-definition/rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
$ref: './rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
$ref: './error-responses.yaml#/components/responses/Forbidden'
"404":
$ref: './api-definition/error-responses.yaml#/components/responses/NotFound'
$ref: './error-responses.yaml#/components/responses/NotFound'
delete:
tags:
- rbacgrants
- rbac-grants
operationId: revokeRoleFromUser
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: grantedRoleUuid
in: path
required: true
@ -58,8 +58,8 @@ delete:
"204":
description: No Content
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
$ref: './error-responses.yaml#/components/responses/Forbidden'
"404":
$ref: './api-definition/error-responses.yaml#/components/responses/NotFound'
$ref: './error-responses.yaml#/components/responses/NotFound'

View File

@ -0,0 +1,43 @@
get:
tags:
- rbac-grants
operationId: listUserGrants
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
post:
tags:
- rbac-grants
operationId: grantRoleToUser
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
requestBody:
required: true
content:
application/json:
schema:
$ref: './rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
responses:
"201":
description: OK
content:
'application/json':
schema:
$ref: './rbac-grant-schemas.yaml#/components/schemas/RbacGrant'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
"409":
$ref: './error-responses.yaml#/components/responses/Conflict'

View File

@ -0,0 +1,16 @@
get:
tags:
- rbac-roles
operationId: listRoles
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './rbac-role-schemas.yaml#/components/schemas/RbacRole'

View File

@ -1,11 +1,11 @@
get:
tags:
- rbacusers
- rbac-users
description: 'List all visible permissions granted to the given user; reduced '
operationId: listUserPermissions
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: userUuid
in: path
required: true
@ -20,9 +20,9 @@ get:
schema:
type: array
items:
$ref: './api-definition/rbac-user-schemas.yaml#/components/schemas/RbacUserPermission'
$ref: './rbac-user-schemas.yaml#/components/schemas/RbacUserPermission'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
$ref: './error-responses.yaml#/components/responses/Forbidden'

View File

@ -0,0 +1,51 @@
get:
tags:
- rbac-users
description: 'Fetch a single user by its id, if visible for the current subject.'
operationId: getUserById
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: userUuid
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './rbac-user-schemas.yaml#/components/schemas/RbacUser'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
delete:
tags:
- rbac-users
operationId: deleteUserByUuid
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: userUuid
in: path
required: true
schema:
type: string
format: uuid
description: UUID of the user to delete.
responses:
"204":
description: No Content
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'
"404":
$ref: './error-responses.yaml#/components/responses/NotFound'

View File

@ -0,0 +1,48 @@
get:
tags:
- rbac-users
description: List accessible RBAC users with optional filter by name.
operationId: listUsers
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: name
in: query
required: false
schema:
type: string
responses:
'200':
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './rbac-user-schemas.yaml#/components/schemas/RbacUser'
'401':
$ref: './error-responses.yaml#/components/responses/Unauthorized'
'403':
$ref: './error-responses.yaml#/components/responses/Forbidden'
post:
tags:
- rbac-users
description: Create a new RBAC user.
operationId: createUser
requestBody:
required: true
content:
application/json:
schema:
$ref: './rbac-user-schemas.yaml#/components/schemas/RbacUser'
responses:
'201':
description: Created
content:
'application/json':
schema:
$ref: './rbac-user-schemas.yaml#/components/schemas/RbacUser'
'409':
$ref: './error-responses.yaml#/components/responses/Conflict'

View File

@ -0,0 +1,28 @@
openapi: 3.0.1
info:
title: Hostsharing hsadmin-ng API
version: v0
servers:
- url: http://localhost:8080
description: Local development default URL.
paths:
/api/rbac/users:
$ref: './rbac-users.yaml'
/api/rbac/users/{userUuid}/permissions:
$ref: './rbac-users-with-id-permissions.yaml'
/api/rbac/users/{userUuid}:
$ref: './rbac-users-with-uuid.yaml'
/api/rbac/roles:
$ref: './rbac-roles.yaml'
/api/rbac/grants:
$ref: './rbac-grants.yaml'
/api/rbac/grants/{grantedRoleUuid}/{granteeUserUuid}:
$ref: './rbac-grants-with-id.yaml'

View File

@ -1,29 +0,0 @@
patch:
tags:
- testPackages
operationId: updatePackage
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- name: packageUUID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
'application/json':
schema:
$ref: './api-definition/test-package-schemas.yaml#/components/schemas/TestPackageUpdate'
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './api-definition/test-package-schemas.yaml#/components/schemas/TestPackage'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'

View File

@ -1,25 +0,0 @@
get:
tags:
- testPackages
operationId: listPackages
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- name: name
in: query
required: false
schema:
type: string
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './api-definition/test-package-schemas.yaml#/components/schemas/TestPackage'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'

View File

@ -0,0 +1,16 @@
openapi-processor-mapping: v2
options:
package-name: net.hostsharing.hsadminng.test.generated.api.v1
model-name-suffix: Resource
map:
result: org.springframework.http.ResponseEntity
types:
- type: array => java.util.List
- type: string:uuid => java.util.UUID
paths:
/api/test/packages/{packageUUID}:
null: org.openapitools.jackson.nullable.JsonNullable

View File

@ -5,8 +5,8 @@ get:
- testCustomers
operationId: listCustomers
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: prefix
in: query
required: false
@ -21,11 +21,11 @@ get:
schema:
type: array
items:
$ref: './api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer'
$ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
$ref: './error-responses.yaml#/components/responses/Forbidden'
post:
summary: Adds a new customer.
@ -33,13 +33,13 @@ post:
- testCustomers
operationId: addCustomer
parameters:
- $ref: './api-definition/auth.yaml#/components/parameters/currentUser'
- $ref: './api-definition/auth.yaml#/components/parameters/assumedRoles'
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
requestBody:
content:
'application/json':
schema:
$ref: './api-definition/api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer'
$ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer'
required: true
responses:
"201":
@ -47,10 +47,10 @@ post:
content:
'application/json':
schema:
$ref: './api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer'
$ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer'
"401":
$ref: './api-definition/error-responses.yaml#/components/responses/Unauthorized'
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './api-definition/error-responses.yaml#/components/responses/Forbidden'
$ref: './error-responses.yaml#/components/responses/Forbidden'
"409":
$ref: './api-definition/error-responses.yaml#/components/responses/Conflict'
$ref: './error-responses.yaml#/components/responses/Conflict'

View File

@ -10,7 +10,7 @@ components:
type: string
format: uuid
customer:
$ref: './api-definition/test-customer-schemas.yaml#/components/schemas/TestCustomer'
$ref: './test-customer-schemas.yaml#/components/schemas/TestCustomer'
name:
type: string
description:

View File

@ -0,0 +1,29 @@
patch:
tags:
- testPackages
operationId: updatePackage
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: packageUUID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
'application/json':
schema:
$ref: './test-package-schemas.yaml#/components/schemas/TestPackageUpdate'
responses:
"200":
description: OK
content:
'application/json':
schema:
$ref: './test-package-schemas.yaml#/components/schemas/TestPackage'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'

View File

@ -0,0 +1,25 @@
get:
tags:
- testPackages
operationId: listPackages
parameters:
- $ref: './auth.yaml#/components/parameters/currentUser'
- $ref: './auth.yaml#/components/parameters/assumedRoles'
- name: name
in: query
required: false
schema:
type: string
responses:
"200":
description: OK
content:
'application/json':
schema:
type: array
items:
$ref: './test-package-schemas.yaml#/components/schemas/TestPackage'
"401":
$ref: './error-responses.yaml#/components/responses/Unauthorized'
"403":
$ref: './error-responses.yaml#/components/responses/Forbidden'

View File

@ -0,0 +1,19 @@
openapi: 3.0.1
info:
title: Hostsharing hsadmin-ng API
version: v0
servers:
- url: http://localhost:8080
description: Local development default URL.
paths:
/api/test/customers:
$ref: "./test-customers.yaml"
/api/test/packages:
$ref: "./test-packages.yaml"
/api/test/packages/{packageUUID}:
$ref: "./test-packages-uuid.yaml"

View File

@ -6,11 +6,3 @@ options:
map:
result: org.springframework.http.ResponseEntity
types:
- type: array => java.util.List
- type: string:uuid => java.util.UUID
paths:
/api/test/packages/{packageUUID}:
null: org.openapitools.jackson.nullable.JsonNullable