a lot of things
This commit is contained in:
+449
-11
@@ -199,6 +199,273 @@ Check if the currently authenticated user has specific permissions. Accepts an a
|
||||
|
||||
---
|
||||
|
||||
## Other User Routes
|
||||
|
||||
### Get All Users
|
||||
|
||||
**GET** `/user/users`
|
||||
|
||||
Fetch a list of all users.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `user.read.other`, `user.list.other`
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "Users Fetched Successfully!",
|
||||
"data": [
|
||||
{
|
||||
"id": "ckx...",
|
||||
"name": "John Doe",
|
||||
"email": "john.doe@example.com",
|
||||
"login": "john.doe",
|
||||
"image": "https://...",
|
||||
"roles": ["admin"]
|
||||
}
|
||||
],
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Get User by ID
|
||||
|
||||
**GET** `/user/users/:identifier`
|
||||
|
||||
Fetch a specific user by their ID.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `user.read.other`
|
||||
|
||||
**Path Parameters:**
|
||||
|
||||
- `identifier` - The user's ID
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "User Fetched Successfully!",
|
||||
"data": {
|
||||
"id": "ckx...",
|
||||
"name": "John Doe",
|
||||
"email": "john.doe@example.com",
|
||||
"login": "john.doe",
|
||||
"image": "https://...",
|
||||
"roles": ["admin"]
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
**Error Response (404):**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 404,
|
||||
"message": "User with identifier 'ckx...' was not found.",
|
||||
"error": "UserNotFound",
|
||||
"successful": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Update User by ID
|
||||
|
||||
**PATCH** `/user/users/:identifier`
|
||||
|
||||
Update a specific user's information. Supports updating profile fields, roles, and direct permissions.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `user.write.other`
|
||||
|
||||
**Conditional Permissions:**
|
||||
|
||||
- If `roles` is included in the body: `user.roles.other` is also required
|
||||
- If `permissions` is included in the body: `user.permissions.other` is also required
|
||||
|
||||
**Path Parameters:**
|
||||
|
||||
- `identifier` - The user's ID
|
||||
|
||||
**Request Body:**
|
||||
|
||||
All fields are optional. Include only the fields you want to update.
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Jane Doe",
|
||||
"image": "https://example.com/avatar.jpg",
|
||||
"roles": ["admin", "moderator"],
|
||||
"permissions": ["credential.fetch", "company.fetch"]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
| ------------- | ---------- | -------------------------------------------------------------- |
|
||||
| `name` | `string` | The user's display name |
|
||||
| `image` | `string` | URL to the user's avatar image |
|
||||
| `roles` | `string[]` | Array of role ids or monikers to assign (replaces all roles) |
|
||||
| `permissions` | `string[]` | Array of permission nodes to assign (replaces all permissions) |
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "User Updated Successfully!",
|
||||
"data": {
|
||||
"id": "ckx...",
|
||||
"name": "Jane Doe",
|
||||
"email": "jane.doe@example.com",
|
||||
"login": "jane.doe",
|
||||
"image": "https://example.com/avatar.jpg",
|
||||
"roles": ["admin", "moderator"]
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
**Error Response (403 - Missing role permission):**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 403,
|
||||
"message": "You do not have permission to modify roles on another user.",
|
||||
"error": "InsufficientPermission",
|
||||
"successful": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Delete User by ID
|
||||
|
||||
**DELETE** `/user/users/:identifier`
|
||||
|
||||
Delete a specific user.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `user.delete.other`
|
||||
|
||||
**Path Parameters:**
|
||||
|
||||
- `identifier` - The user's ID
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "User Deleted Successfully!",
|
||||
"data": {
|
||||
"id": "ckx...",
|
||||
"name": "John Doe",
|
||||
"email": "john.doe@example.com",
|
||||
"login": "john.doe",
|
||||
"image": "https://...",
|
||||
"roles": ["admin"]
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Get User Roles
|
||||
|
||||
**GET** `/user/users/:identifier/roles`
|
||||
|
||||
Fetch all roles assigned to a specific user.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `user.read.other`, `role.read`
|
||||
|
||||
**Path Parameters:**
|
||||
|
||||
- `identifier` - The user's ID
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "User Roles Fetched Successfully!",
|
||||
"data": [
|
||||
{
|
||||
"id": "uuid...",
|
||||
"title": "Administrator",
|
||||
"moniker": "admin",
|
||||
"permissions": ["*"]
|
||||
}
|
||||
],
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Check User Permissions (Other User)
|
||||
|
||||
**POST** `/user/users/:identifier/check-permission`
|
||||
|
||||
Check if a specific user has certain permissions.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `user.read.other`
|
||||
|
||||
**Path Parameters:**
|
||||
|
||||
- `identifier` - The user's ID
|
||||
|
||||
**Request Body:**
|
||||
|
||||
```json
|
||||
{
|
||||
"permissions": ["user.read", "company.fetch", "credential.write"]
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "Permission check completed.",
|
||||
"data": {
|
||||
"results": [
|
||||
{
|
||||
"permission": "user.read",
|
||||
"hasPermission": true
|
||||
},
|
||||
{
|
||||
"permission": "company.fetch",
|
||||
"hasPermission": false
|
||||
},
|
||||
{
|
||||
"permission": "credential.write",
|
||||
"hasPermission": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Company Routes
|
||||
|
||||
### Get All Companies
|
||||
@@ -342,6 +609,34 @@ Fetch configurations for a specific company from ConnectWise.
|
||||
|
||||
## Credential Routes
|
||||
|
||||
### Get Value Types
|
||||
|
||||
**GET** `/credential/valuetypes`
|
||||
|
||||
Returns all available field value types for credential type fields.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "Value Types Fetched Successfully!",
|
||||
"data": [
|
||||
"plain_text",
|
||||
"license_key",
|
||||
"ip_address",
|
||||
"generic_secret",
|
||||
"bitlocker_key",
|
||||
"password"
|
||||
],
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Get Credential by ID
|
||||
|
||||
**GET** `/credential/credentials/:id`
|
||||
@@ -365,11 +660,27 @@ Fetch a single credential by its ID.
|
||||
"data": {
|
||||
"id": "ckx...",
|
||||
"name": "AWS Credentials",
|
||||
"notes": null,
|
||||
"typeId": "cky...",
|
||||
"companyId": "ckz...",
|
||||
"fields": {
|
||||
"accountId": "123456789"
|
||||
},
|
||||
"fields": [
|
||||
{
|
||||
"id": "accessKeyId",
|
||||
"name": "Access Key ID",
|
||||
"secure": false,
|
||||
"required": true,
|
||||
"valueType": "plain_text",
|
||||
"value": "AKIAIOSFODNN7EXAMPLE"
|
||||
},
|
||||
{
|
||||
"id": "secretAccessKey",
|
||||
"name": "Secret Access Key",
|
||||
"secure": true,
|
||||
"required": true,
|
||||
"valueType": "password",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"type": {
|
||||
"id": "cky...",
|
||||
"name": "AWS",
|
||||
@@ -413,9 +724,27 @@ Fetch all credentials associated with a specific company.
|
||||
{
|
||||
"id": "ckx...",
|
||||
"name": "AWS Credentials",
|
||||
"notes": null,
|
||||
"typeId": "cky...",
|
||||
"companyId": "ckz...",
|
||||
"fields": {...},
|
||||
"fields": [
|
||||
{
|
||||
"id": "accessKeyId",
|
||||
"name": "Access Key ID",
|
||||
"secure": false,
|
||||
"required": true,
|
||||
"valueType": "plain_text",
|
||||
"value": "AKIAIOSFODNN7EXAMPLE"
|
||||
},
|
||||
{
|
||||
"id": "secretAccessKey",
|
||||
"name": "Secret Access Key",
|
||||
"secure": true,
|
||||
"required": true,
|
||||
"valueType": "password",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"type": {...},
|
||||
"company": {...}
|
||||
}
|
||||
@@ -441,6 +770,7 @@ Create a new credential with validated and encrypted fields.
|
||||
```json
|
||||
{
|
||||
"name": "Production AWS Credentials",
|
||||
"notes": "Used for production S3 access",
|
||||
"typeId": "cky...",
|
||||
"companyId": "ckz...",
|
||||
"fields": [
|
||||
@@ -469,7 +799,26 @@ Create a new credential with validated and encrypted fields.
|
||||
"name": "Production AWS Credentials",
|
||||
"typeId": "cky...",
|
||||
"companyId": "ckz...",
|
||||
"fields": {...}
|
||||
"fields": [
|
||||
{
|
||||
"id": "accessKeyId",
|
||||
"name": "Access Key ID",
|
||||
"secure": false,
|
||||
"required": true,
|
||||
"valueType": "plain_text",
|
||||
"value": "AKIAIOSFODNN7EXAMPLE"
|
||||
},
|
||||
{
|
||||
"id": "secretAccessKey",
|
||||
"name": "Secret Access Key",
|
||||
"secure": true,
|
||||
"required": true,
|
||||
"valueType": "password",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"type": {...},
|
||||
"company": {...}
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
@@ -481,7 +830,7 @@ Create a new credential with validated and encrypted fields.
|
||||
|
||||
**PATCH** `/credential/credentials/:id`
|
||||
|
||||
Update a credential's basic properties (name).
|
||||
Update a credential's basic properties (name, notes) and/or field values. Secure fields are automatically encrypted.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
@@ -493,9 +842,22 @@ Update a credential's basic properties (name).
|
||||
|
||||
**Request Body:**
|
||||
|
||||
All properties are optional. Include only the properties you want to update.
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Updated Credential Name"
|
||||
"name": "Updated Credential Name",
|
||||
"notes": "Updated notes for this credential",
|
||||
"fields": [
|
||||
{
|
||||
"fieldId": "accessKeyId",
|
||||
"value": "AKIAIOSFODNN7EXAMPLE"
|
||||
},
|
||||
{
|
||||
"fieldId": "secretAccessKey",
|
||||
"value": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -508,7 +870,21 @@ Update a credential's basic properties (name).
|
||||
"data": {
|
||||
"id": "ckx...",
|
||||
"name": "Updated Credential Name",
|
||||
...
|
||||
"notes": "Updated notes for this credential",
|
||||
"typeId": "cky...",
|
||||
"companyId": "ckz...",
|
||||
"fields": [
|
||||
{
|
||||
"id": "accessKeyId",
|
||||
"name": "Access Key ID",
|
||||
"secure": false,
|
||||
"required": true,
|
||||
"valueType": "plain_text",
|
||||
"value": "AKIAIOSFODNN7EXAMPLE"
|
||||
}
|
||||
],
|
||||
"type": {...},
|
||||
"company": {...}
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
@@ -536,12 +912,10 @@ Validate and update credential field values. Secure fields are automatically enc
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"id": "ckx1...",
|
||||
"fieldId": "accessKeyId",
|
||||
"value": "AKIAIOSFODNN7NEWVALUE"
|
||||
},
|
||||
{
|
||||
"id": "ckx2...",
|
||||
"fieldId": "secretAccessKey",
|
||||
"value": "newSecretKeyValue123"
|
||||
}
|
||||
@@ -558,7 +932,29 @@ Validate and update credential field values. Secure fields are automatically enc
|
||||
"data": {
|
||||
"id": "ckx...",
|
||||
"name": "Production AWS Credentials",
|
||||
"fields": {...}
|
||||
"notes": null,
|
||||
"typeId": "cky...",
|
||||
"companyId": "ckz...",
|
||||
"fields": [
|
||||
{
|
||||
"id": "accessKeyId",
|
||||
"name": "Access Key ID",
|
||||
"secure": false,
|
||||
"required": true,
|
||||
"valueType": "plain_text",
|
||||
"value": "AKIAIOSFODNN7NEWVALUE"
|
||||
},
|
||||
{
|
||||
"id": "secretAccessKey",
|
||||
"name": "Secret Access Key",
|
||||
"secure": true,
|
||||
"required": true,
|
||||
"valueType": "password",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"type": {...},
|
||||
"company": {...}
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
@@ -634,6 +1030,48 @@ Decrypt and return all secure field values for a credential.
|
||||
|
||||
---
|
||||
|
||||
### Read Single Secure Value
|
||||
|
||||
**GET** `/credential/credentials/:id/secure-values/:fieldId`
|
||||
|
||||
Decrypt and return a single secure field value for a credential.
|
||||
|
||||
**Authentication Required:** Yes
|
||||
|
||||
**Required Permissions:** `credential.fetch`, `credential.secure_values.read`
|
||||
|
||||
**URL Parameters:**
|
||||
|
||||
- `id` - Credential ID
|
||||
- `fieldId` - The field ID of the secure value to read
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "Secure Value Fetched Successfully!",
|
||||
"data": {
|
||||
"fieldId": "secretAccessKey",
|
||||
"value": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
||||
},
|
||||
"successful": true
|
||||
}
|
||||
```
|
||||
|
||||
**Error Response (404):**
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 404,
|
||||
"message": "Secure field not found: unknownField",
|
||||
"error": "SecureFieldNotFound",
|
||||
"successful": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Delete Credential
|
||||
|
||||
**DELETE** `/credential/credentials/:id`
|
||||
|
||||
Reference in New Issue
Block a user