Compare commits
7 Commits
fix/users-
...
eae947d9b6
| Author | SHA1 | Date | |
|---|---|---|---|
| eae947d9b6 | |||
| a2f626557e | |||
| c5827db872 | |||
| 7326cadfec | |||
| 1b10c97099 | |||
| 8434a5d226 | |||
| a2ab541b73 |
37
Dockerfile
37
Dockerfile
@@ -1,25 +1,46 @@
|
||||
FROM python:3.11-slim
|
||||
# Stage 1: build dependencies
|
||||
FROM python:3.11-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
default-libmysqlclient-dev \
|
||||
pkg-config \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Pre-download wheels to avoid recompiling bcrypt from source
|
||||
RUN pip install --no-cache-dir --prefix=/install \
|
||||
'bcrypt==4.0.1' \
|
||||
'cffi>=2.0' \
|
||||
'pycparser>=2.0'
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
||||
|
||||
# Stage 2: slim runtime
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install runtime dependencies only (no build tools)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
default-libmysqlclient-dev \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy installed packages from builder
|
||||
COPY --from=builder /install /usr/local
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
COPY app/ ./app/
|
||||
COPY requirements.txt ./
|
||||
|
||||
# Make entrypoint
|
||||
COPY entrypoint.sh .
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
# Wait for wizard config, then start uvicorn
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
|
||||
@@ -241,7 +241,7 @@ def delete_user(
|
||||
def reset_user_apikey(
|
||||
identifier: str,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: models.User = Depends(get_current_user),
|
||||
current_user: models.User = Depends(get_current_user_or_apikey),
|
||||
):
|
||||
"""Reset (regenerate) a user's API key.
|
||||
|
||||
@@ -249,6 +249,8 @@ def reset_user_apikey(
|
||||
- user.reset-apikey: can reset any user's API key
|
||||
- user.reset-self-apikey: can reset only own API key
|
||||
- admin: can reset any user's API key
|
||||
|
||||
Accepts both OAuth2 Bearer token and X-API-Key authentication.
|
||||
"""
|
||||
import secrets
|
||||
from app.models.apikey import APIKey
|
||||
|
||||
@@ -189,6 +189,7 @@ _DEV_PERMISSIONS = {
|
||||
|
||||
_ACCOUNT_MANAGER_PERMISSIONS = {
|
||||
"account.create",
|
||||
"user.reset-apikey",
|
||||
}
|
||||
|
||||
# Role definitions: (name, description, permission_set)
|
||||
|
||||
Reference in New Issue
Block a user