diff options
| author | haturatu <taro@eyes4you.org> | 2025-10-13 01:41:44 +0900 |
|---|---|---|
| committer | haturatu <taro@eyes4you.org> | 2025-10-13 01:41:44 +0900 |
| commit | bb4fdc82353e3a0baef835bd0dce72c4eca74df0 (patch) | |
| tree | 569f081aee65c0d9f078cb2dd012d75c403215ef /README.md | |
| parent | d758543bf215ff224dcb57f774180fa8e4279f9f (diff) | |
fix(api): api endpoint csrf
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 89 |
1 files changed, 89 insertions, 0 deletions
@@ -341,6 +341,95 @@ The `refresh_token` is a long-lived token that can be used to obtain a new acces **Note:** The token lifetimes can be configured in your `.env` file. See the configuration table for details. +## Admin API Endpoints + +For administrative tasks, the proxy provides several API endpoints that can be accessed programmatically. All of these endpoints require a valid Bearer Token from a user with the `admin` role. + +The base path for these endpoints is `/api/admin/users`, which can be customized with the `AUTH_PATH_ADMIN_USERS_API` environment variable. + +### List Users + +- **Endpoint**: `GET /api/admin/users` +- **Description**: Retrieves a list of all users in the system. +- **Example**: + ```sh + ACCESS_TOKEN="your_admin_access_token" + curl -H "Authorization: Bearer $ACCESS_TOKEN" http://localhost:8080/api/admin/users + ``` + +### Create User + +- **Endpoint**: `POST /api/admin/users` +- **Description**: Creates a new user. +- **Body**: + ```json + { + "username": "newuser", + "password": "a-strong-password", + "role": "user" + } + ``` +- **Example**: + ```sh + ACCESS_TOKEN="your_admin_access_token" + curl -X POST -H "Authorization: Bearer $ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"username": "newuser", "password": "Password123", "role": "user"}' \ + http://localhost:8080/api/admin/users + ``` + +### Update User Role + +- **Endpoint**: `POST /api/admin/users/{id}/role` +- **Description**: Updates the role of a specific user by their ID. +- **Body**: + ```json + { + "role": "admin" + } + ``` +- **Example**: + ```sh + USER_ID=2 + ACCESS_TOKEN="your_admin_access_token" + curl -X POST -H "Authorization: Bearer $ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"role": "admin"}' \ + http://localhost:8080/api/admin/users/$USER_ID/role + ``` + +### Update User Status + +- **Endpoint**: `POST /api/admin/users/{id}/status` +- **Description**: Activates or deactivates a user by their ID. +- **Body**: + ```json + { + "is_active": false + } + ``` +- **Example**: + ```sh + USER_ID=2 + ACCESS_TOKEN="your_admin_access_token" + curl -X POST -H "Authorization: Bearer $ACCESS_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"is_active": false}' \ + http://localhost:8080/api/admin/users/$USER_ID/status + ``` + +### Delete User + +- **Endpoint**: `DELETE /api/admin/users/{id}` +- **Description**: Deletes a user by their ID. +- **Example**: + ```sh + USER_ID=2 + ACCESS_TOKEN="your_admin_access_token" + curl -X DELETE -H "Authorization: Bearer $ACCESS_TOKEN" \ + http://localhost:8080/api/admin/users/$USER_ID + ``` + ## Configuration Details | Environment Variable | Description | Default Value | |
