Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,77 +1,77 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Prolog Gateway
|
| 3 |
-
emoji: 📊
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: pink
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
-
---
|
| 9 |
-
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 11 |
-
|
| 12 |
-
## Authentication
|
| 13 |
-
|
| 14 |
-
The gateway uses JWT for authenticated access to proxy endpoints.
|
| 15 |
-
|
| 16 |
-
### Multi-user login
|
| 17 |
-
|
| 18 |
-
User credentials are stored and managed in the **private backend**. The public gateway proxies login/registration requests to the backend and issues JWTs to the frontend.
|
| 19 |
-
|
| 20 |
-
Configure one or more initial users via environment variables on the **backend Space**:
|
| 21 |
-
|
| 22 |
-
- `APP_USERS_JSON`: JSON object mapping `username -> plaintext_password` (recommended for demos; store as secrets)
|
| 23 |
-
- `APP_USERS_HASHED_JSON`: JSON object mapping `username -> werkzeug_password_hash` (recommended for production)
|
| 24 |
-
- `APP_USER` / `APP_PASSWORD`: legacy single-user plaintext credentials (still supported)
|
| 25 |
-
- `TEST_USER_PASSWORD`: if set, enables a `test_user` account with this password
|
| 26 |
-
|
| 27 |
-
Persistence:
|
| 28 |
-
|
| 29 |
-
- The backend stores users in a **SQLite database** (passwords are hashed).
|
| 30 |
-
- Configure the DB file path on the backend with `USER_DB_PATH` (use a persistent mount such as `/data/users.db` if available).
|
| 31 |
-
|
| 32 |
-
Seeding behavior (backend):
|
| 33 |
-
|
| 34 |
-
- On startup, the backend **seeds** users from `APP_USERS_JSON`, `APP_USERS_HASHED_JSON`, `APP_USER/APP_PASSWORD`, and `TEST_USER_PASSWORD`.
|
| 35 |
-
- Seeding **does not overwrite existing passwords**; it only adds missing users and updates admin flags.
|
| 36 |
-
|
| 37 |
-
Examples:
|
| 38 |
-
|
| 39 |
-
- `APP_USERS_JSON={"alice":"pw1","bob":"pw2","test_user":"pw3"}`
|
| 40 |
-
- `TEST_USER_PASSWORD=changeme` (creates user `test_user`)
|
| 41 |
-
|
| 42 |
-
Notes:
|
| 43 |
-
|
| 44 |
-
- Do not hardcode passwords in the repo. Use Hugging Face Space secrets or your deployment secret store.
|
| 45 |
-
- The JWT identity is set to the username.
|
| 46 |
-
|
| 47 |
-
### Admin-only user registration
|
| 48 |
-
|
| 49 |
-
The gateway can create users at runtime via `POST /register`.
|
| 50 |
-
|
| 51 |
-
- Requires a valid JWT (`Authorization: Bearer ...`).
|
| 52 |
-
- Only allowed if the JWT identity (username) is in `ADMIN_USERS`.
|
| 53 |
-
|
| 54 |
-
Env vars (backend):
|
| 55 |
-
|
| 56 |
-
- `ADMIN_USERS`: comma-separated usernames who can call `/register` (e.g. `ADMIN_USERS=alice,bob`)
|
| 57 |
-
- If `ADMIN_USERS` is not set but `APP_USER` is set, `APP_USER` is treated as the admin for convenience.
|
| 58 |
-
|
| 59 |
-
Request body:
|
| 60 |
-
|
| 61 |
-
```json
|
| 62 |
-
{ "username": "new_user", "password": "pw", "overwrite": false }
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
Notes:
|
| 66 |
-
|
| 67 |
-
- Users created via `/register` are stored in the backend SQLite DB at `USER_DB_PATH` (persist across restarts).
|
| 68 |
-
|
| 69 |
-
### Current user info
|
| 70 |
-
|
| 71 |
-
`GET /me` (JWT required) returns the current username and whether the user is an admin:
|
| 72 |
-
|
| 73 |
-
```json
|
| 74 |
-
{ "ok": true, "username": "alice", "is_admin": true }
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
- Used by the frontend to show the “Register User” panel only for admins.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Prolog AI Gateway - Basic
|
| 3 |
+
emoji: 📊
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: pink
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 11 |
+
|
| 12 |
+
## Authentication
|
| 13 |
+
|
| 14 |
+
The gateway uses JWT for authenticated access to proxy endpoints.
|
| 15 |
+
|
| 16 |
+
### Multi-user login
|
| 17 |
+
|
| 18 |
+
User credentials are stored and managed in the **private backend**. The public gateway proxies login/registration requests to the backend and issues JWTs to the frontend.
|
| 19 |
+
|
| 20 |
+
Configure one or more initial users via environment variables on the **backend Space**:
|
| 21 |
+
|
| 22 |
+
- `APP_USERS_JSON`: JSON object mapping `username -> plaintext_password` (recommended for demos; store as secrets)
|
| 23 |
+
- `APP_USERS_HASHED_JSON`: JSON object mapping `username -> werkzeug_password_hash` (recommended for production)
|
| 24 |
+
- `APP_USER` / `APP_PASSWORD`: legacy single-user plaintext credentials (still supported)
|
| 25 |
+
- `TEST_USER_PASSWORD`: if set, enables a `test_user` account with this password
|
| 26 |
+
|
| 27 |
+
Persistence:
|
| 28 |
+
|
| 29 |
+
- The backend stores users in a **SQLite database** (passwords are hashed).
|
| 30 |
+
- Configure the DB file path on the backend with `USER_DB_PATH` (use a persistent mount such as `/data/users.db` if available).
|
| 31 |
+
|
| 32 |
+
Seeding behavior (backend):
|
| 33 |
+
|
| 34 |
+
- On startup, the backend **seeds** users from `APP_USERS_JSON`, `APP_USERS_HASHED_JSON`, `APP_USER/APP_PASSWORD`, and `TEST_USER_PASSWORD`.
|
| 35 |
+
- Seeding **does not overwrite existing passwords**; it only adds missing users and updates admin flags.
|
| 36 |
+
|
| 37 |
+
Examples:
|
| 38 |
+
|
| 39 |
+
- `APP_USERS_JSON={"alice":"pw1","bob":"pw2","test_user":"pw3"}`
|
| 40 |
+
- `TEST_USER_PASSWORD=changeme` (creates user `test_user`)
|
| 41 |
+
|
| 42 |
+
Notes:
|
| 43 |
+
|
| 44 |
+
- Do not hardcode passwords in the repo. Use Hugging Face Space secrets or your deployment secret store.
|
| 45 |
+
- The JWT identity is set to the username.
|
| 46 |
+
|
| 47 |
+
### Admin-only user registration
|
| 48 |
+
|
| 49 |
+
The gateway can create users at runtime via `POST /register`.
|
| 50 |
+
|
| 51 |
+
- Requires a valid JWT (`Authorization: Bearer ...`).
|
| 52 |
+
- Only allowed if the JWT identity (username) is in `ADMIN_USERS`.
|
| 53 |
+
|
| 54 |
+
Env vars (backend):
|
| 55 |
+
|
| 56 |
+
- `ADMIN_USERS`: comma-separated usernames who can call `/register` (e.g. `ADMIN_USERS=alice,bob`)
|
| 57 |
+
- If `ADMIN_USERS` is not set but `APP_USER` is set, `APP_USER` is treated as the admin for convenience.
|
| 58 |
+
|
| 59 |
+
Request body:
|
| 60 |
+
|
| 61 |
+
```json
|
| 62 |
+
{ "username": "new_user", "password": "pw", "overwrite": false }
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
Notes:
|
| 66 |
+
|
| 67 |
+
- Users created via `/register` are stored in the backend SQLite DB at `USER_DB_PATH` (persist across restarts).
|
| 68 |
+
|
| 69 |
+
### Current user info
|
| 70 |
+
|
| 71 |
+
`GET /me` (JWT required) returns the current username and whether the user is an admin:
|
| 72 |
+
|
| 73 |
+
```json
|
| 74 |
+
{ "ok": true, "username": "alice", "is_admin": true }
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
- Used by the frontend to show the “Register User” panel only for admins.
|