refactor: update ADMIN_USER_CODES configuration; move to auth_api and clarify usage in documentation
Build and Push Docker Images / build-auth-api (push) Has been cancelled
Build and Push Docker Images / build-employee-api (push) Failing after 2m52s
Build and Push Docker Images / build-admin-ui (push) Failing after 24s
Build and Push Docker Images / build-transit-api (push) Failing after 26s
Build and Push Docker Images / build-error-log-api (push) Failing after 27s

This commit is contained in:
Sven laptop
2026-05-18 00:33:43 +02:00
parent 0e19aa0521
commit 9a56b40f50
4 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ POSTGRES_PASSWORD_AUTH=your_password
POSTGRES_USER_TRANSIT=transitAPI
POSTGRES_PASSWORD_TRANSIT=your_password
JWT_SECRET=your-secure-secret
ADMIN_USER_CODES=42
# ADMIN_USER_CODES should be set in auth_api/.env (comma-separated admin user codes)
```
### Step 3: Start Services
+5 -3
View File
@@ -370,10 +370,11 @@ Admin dashboard uses simple JWT-based authentication:
2. Receive JWT token from `auth_api`
3. Use token for admin operations (`/admin/*` endpoints)
Admin authorization is controlled by `ADMIN_USER_CODES` environment variable:
Admin authorization is controlled by `ADMIN_USER_CODES` environment variable configured in the `auth_api` service:
```bash
ADMIN_USER_CODES=42,101,205 # Comma-separated admin user codes
# Set admin user codes for the auth service (comma-separated)
ADMIN_USER_CODES=42,101,205
```
---
@@ -385,7 +386,8 @@ ADMIN_USER_CODES=42,101,205 # Comma-separated admin user codes
Use `DEV_MOCK=1` to work without a database (in-memory mock storage):
```bash
ADMIN_USER_CODES=42 DEV_MOCK=1 JWT_SECRET=devsecret npm --prefix ./transit_api start
# For local development set admin codes on the auth_api and start services
ADMIN_USER_CODES=42 DEV_MOCK=1 JWT_SECRET=devsecret npm --prefix ./auth_api start
```
### Production Mode
+1 -1
View File
@@ -134,7 +134,7 @@ All requests include JWT Bearer token for authentication.
### Admin Authorization
Users must have a `userCode` in their JWT that matches `ADMIN_USER_CODES` environment variable in the transit API to access admin endpoints.
Users must have a `userCode` in their JWT and, for admin access, the `isAdmin` flag set by the `auth_api` based on the `ADMIN_USER_CODES` environment variable.
### Production Setup
+2 -1
View File
@@ -42,10 +42,11 @@ PG_USER=your_user
PG_PASS=your_password
PG_DB=your_database
JWT_SECRET=your_jwt_secret
ADMIN_USER_CODES=12345,67890
PORT=5001
```
Note: `ADMIN_USER_CODES` has been moved to the `auth_api` service. Configure admin user codes in `auth_api/.env` as a comma-separated list.
### 4. API starten
```bash