fully implement acl backend and interface

This commit is contained in:
2025-12-21 22:18:29 +02:00
parent 85f8ac60e7
commit e9d8877fbf
15 changed files with 1567 additions and 166 deletions

View File

@@ -17,6 +17,18 @@ definitions:
example: https://api.triggerssmith.com/errors/role-not-found
type: string
type: object
api_acladmin.assignResourceToRoleRequest:
properties:
resourceId:
example: 1
type: integer
type: object
api_acladmin.assignRoleToUserRequest:
properties:
roleId:
example: 1
type: integer
type: object
api_acladmin.createResourceRequest:
properties:
key:
@@ -56,6 +68,15 @@ definitions:
example: html.view
type: string
type: object
api_acladmin.getRoleResource:
properties:
id:
example: 1
type: integer
name:
example: '*'
type: string
type: object
api_acladmin.getRoleResponse:
properties:
id:
@@ -67,16 +88,25 @@ definitions:
type: object
api_acladmin.getRoleUser:
properties:
userEmail:
email:
example: admin@triggerssmith.com
type: string
userId:
id:
example: 1
type: integer
userName:
username:
example: admin
type: string
type: object
api_acladmin.getUserRole:
properties:
id:
example: 1
type: integer
name:
example: '*'
type: string
type: object
api_acladmin.updateResourceRequest:
properties:
key:
@@ -136,7 +166,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get all resources
tags:
- resources
- acl/resources
post:
consumes:
- application/json
@@ -168,7 +198,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Create resource
tags:
- resources
- acl/resources
/api/acl/resources/{resourceId}:
delete:
parameters:
@@ -201,7 +231,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Delete resource
tags:
- resources
- acl/resources
get:
parameters:
- description: Resource ID
@@ -231,7 +261,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get resource by ID
tags:
- resources
- acl/resources
patch:
consumes:
- application/json
@@ -273,7 +303,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Update resource
tags:
- resources
- acl/resources
/api/acl/roles:
get:
produces:
@@ -300,7 +330,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get all roles
tags:
- roles
- acl/roles
post:
consumes:
- application/json
@@ -332,7 +362,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Create role
tags:
- roles
- acl/roles
/api/acl/roles/{roleId}:
delete:
parameters:
@@ -345,8 +375,8 @@ paths:
produces:
- application/json
responses:
"200":
description: OK
"204":
description: No Content
"400":
description: Bad Request
schema:
@@ -365,7 +395,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Delete role
tags:
- roles
- acl/roles
get:
parameters:
- description: Role ID
@@ -395,7 +425,7 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get role by ID
tags:
- roles
- acl/roles
patch:
consumes:
- application/json
@@ -437,7 +467,115 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Update role
tags:
- roles
- acl/roles
/api/acl/roles/{roleId}/resources:
get:
parameters:
- description: Role ID
example: 1
in: path
name: roleId
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
items:
$ref: '#/definitions/api_acladmin.getRoleResource'
type: array
type: array
"400":
description: Bad Request
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"404":
description: Not Found
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get role resources
tags:
- acl/roles
post:
parameters:
- description: Role ID
example: 1
in: path
name: roleId
required: true
type: integer
- description: Resource
in: body
name: request
required: true
schema:
$ref: '#/definitions/api_acladmin.assignResourceToRoleRequest'
produces:
- application/json
responses:
"201":
description: Created
"400":
description: Bad Request
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"404":
description: Not Found
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"409":
description: Conflict
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Assign resource to role
tags:
- acl/roles
/api/acl/roles/{roleId}/resources/{resId}:
delete:
parameters:
- description: Role ID
example: 1
in: path
name: roleId
required: true
type: integer
- description: Resource ID
example: 1
in: path
name: resId
required: true
type: integer
produces:
- application/json
responses:
"204":
description: No Content
"400":
description: Bad Request
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"404":
description: Not Found
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Remove resource from role
tags:
- acl/roles
/api/acl/roles/{roleId}/users:
get:
parameters:
@@ -472,5 +610,111 @@ paths:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get role users
tags:
- roles
- acl/roles
/api/acl/users/{userId}/roles:
get:
parameters:
- description: User ID
example: 1
in: path
name: userId
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/api_acladmin.getUserRole'
type: array
"400":
description: Bad Request
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"404":
description: Not Found
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Get user roles by user ID
tags:
- acl/users
post:
parameters:
- description: User ID
example: 1
in: path
name: userId
required: true
type: integer
- description: Role ID
in: body
name: body
required: true
schema:
$ref: '#/definitions/api_acladmin.assignRoleToUserRequest'
produces:
- application/json
responses:
"201":
description: Created
"400":
description: Bad Request
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"404":
description: Not Found
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"409":
description: Conflict
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Assign role to user
tags:
- acl/users
/api/acl/users/{userId}/roles/{roleId}:
delete:
parameters:
- description: User ID
example: 1
in: path
name: userId
required: true
type: integer
- description: Role ID
example: 1
in: path
name: roleId
required: true
type: integer
produces:
- application/json
responses:
"204":
description: No Content
"400":
description: Bad Request
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"404":
description: Not Found
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/api_acladmin.ProblemDetails'
summary: Remove role from user
tags:
- acl/users
swagger: "2.0"