🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Add optimized Dockerfile with multi-stage build and best practices
Erwan Hervé2beb1ac1d9db
diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.shnew file mode 100644index 0000000..9faf6e0--- /dev/null+++ b/Docker/entrypoint.sh@@ -0,0 +1,52 @@+#!/bin/bash+set -euo pipefail++echo "=== Warracker Startup ==="++# Logging function+log() {+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"+}++# Database connection check (with retry)+log "Waiting for database connection..."+for i in {1..30}; do+ if pg_isready -h "${DB_HOST:-localhost}" -p "${DB_PORT:-5432}" -U "${DB_USER:-postgres}" > /dev/null 2>&1; then+ log "Database is ready!"+ break+ fi+ if [ $i -eq 30 ]; then+ log "ERROR: Database not available after 30 attempts"+ exit 1+ fi+ sleep 2+done++# Migrations and permissions+log "Running database migrations..."+python /app/migrations/apply_migrations.py++log "Fixing permissions..."+python /app/fix_permissions.py++# Translation compilation+log "Compiling translations..."+cd /app+pybabel compile -d locales 2>/dev/null || log "Warning: Translation compilation failed"++# Nginx configuration (create temp file, root will move it)+log "Preparing nginx configuration..."+EFFECTIVE_SIZE="${NGINX_MAX_BODY_SIZE_VALUE:-32M}"+if ! echo "${EFFECTIVE_SIZE}" | grep -Eq "^[0-9]+[mMkKgG]?$"; then+ log "Warning: Invalid NGINX_MAX_BODY_SIZE_VALUE. Using default 32M"+ EFFECTIVE_SIZE="32M"+fi+sed "s|__NGINX_MAX_BODY_SIZE_CONFIG_VALUE__|${EFFECTIVE_SIZE}|g" \+ /etc/nginx/conf.d/default.conf.template > /tmp/nginx-default.conf++log "Nginx config prepared (size: ${EFFECTIVE_SIZE})"+log "Setup completed successfully!"++# Execute the CMD (supervisor) by replacing this shell process+log "Starting supervisor..."+exec "$@"diff --git a/Docker/nginx-wrapper.sh b/Docker/nginx-wrapper.shnew file mode 100644index 0000000..d45a253--- /dev/null+++ b/Docker/nginx-wrapper.sh@@ -0,0 +1,22 @@+#!/bin/bash+set -euo pipefail+echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting Nginx..."++# Wait for setup to create the nginx config+for i in {1..30}; do+ if [ -f /tmp/nginx-default.conf ]; then+ mv /tmp/nginx-default.conf /etc/nginx/conf.d/default.conf+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] Nginx configuration applied"+ break+ fi+ if [ $i -eq 30 ]; then+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: Using template config"+ cp /etc/nginx/conf.d/default.conf.template /etc/nginx/conf.d/default.conf+ fi+ sleep 1+done++# Test nginx configuration+nginx -t++exec /usr/sbin/nginx -g 'daemon off;'diff --git a/Docker/supervisord.conf b/Docker/supervisord.confnew file mode 100644index 0000000..882d7b3--- /dev/null+++ b/Docker/supervisord.conf@@ -0,0 +1,38 @@+[supervisord]+nodaemon=true+user=root+logfile=/dev/stdout+logfile_maxbytes=0+pidfile=/var/run/supervisord.pid+childlogdir=/var/log/supervisor++[program:nginx]+command=/app/nginx-wrapper.sh+user=root+autostart=true+autorestart=true+startsecs=5+startretries=5+priority=10+stdout_logfile=/dev/stdout+stdout_logfile_maxbytes=0+stderr_logfile=/dev/stderr+stderr_logfile_maxbytes=0++[program:gunicorn]+command=/usr/local/bin/gunicorn --config /app/gunicorn_config.py 'backend:create_app()'+directory=/app+user=warracker+autostart=true+autorestart=true+startsecs=5+startretries=5+priority=20+stopsignal=QUIT+stopwaitsecs=10+killasgroup=true+stopasgroup=true+stdout_logfile=/dev/stdout+stdout_logfile_maxbytes=0+stderr_logfile=/dev/stderr+stderr_logfile_maxbytes=0diff --git a/Dockerfile b/Dockerfileindex 7fcd630..d7b944c 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,197 +1,108 @@-# Start with Python base image-FROM python:3.12-slim-bookworm-LABEL org.opencontainers.image.source="https://github.com/sassanix/Warracker"-# Install build tools, dev headers, nginx, etc.++FROM python:3.13-slim-trixie AS builder++# Install build tools (only in builder stage)RUN apt-get update && \apt-get install -y --no-install-recommends \build-essential \libpq-dev \+ libcurl4-openssl-dev \+ libssl-dev \+ pkg-config && \+ apt-get clean && \+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*++# Upgrade pip+RUN pip install --no-cache-dir --upgrade pip++# Install Python dependencies (system-wide installation)+COPY backend/requirements.txt /tmp/requirements.txt+RUN pip install --no-cache-dir -r /tmp/requirements.txt+++FROM python:3.13-slim-trixie AS runtime++# Metadata for final image+LABEL org.opencontainers.image.source="https://github.com/sassanix/Warracker"+LABEL org.opencontainers.image.description="Warracker - Warranty Tracker"++# Install runtime dependencies only+RUN apt-get update && \+ apt-get install -y --no-install-recommends \nginx \- curl \- postgresql-client \supervisor \+ postgresql-client \gettext-base \- libcurl4-openssl-dev \- libssl-dev \- ca-certificates && \+ curl \+ ca-certificates \+ libpq5 \+ libcurl4 \+ libssl3 && \apt-get clean && \- rm -rf /var/lib/apt/lists/*-# (build-essential = C compiler + tools)-# (libpq-dev = provides pg_config for psycopg2)+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*++# Create non-root user with home directory+RUN groupadd -r -g 999 warracker && \+ useradd -r -g warracker -u 999 -d /home/warracker -m -s /bin/bash warracker+# Copy Python dependencies from builder (version-agnostic with wildcard)+COPY --from=builder /usr/local/lib/python3.*/site-packages /usr/local/lib/python3.*/site-packages+COPY --from=builder /usr/local/bin /usr/local/bin-# Nginx will be started with "daemon off;" via supervisor, so no need to sed the main nginx.conf+# Configure directories with proper permissions+RUN mkdir -p /app /var/www/html /var/log/supervisor /run/nginx && \+ chown -R warracker:warracker /app /var/www/html /var/log/supervisor /run/nginx /home/warracker && \+ chown -R warracker:warracker /var/log/nginx+# Set working directoryWORKDIR /app-# (Optional) Upgrade pip to latest-RUN pip install --no-cache-dir --upgrade pip+# 1. Configuration and static files first (rarely change)+COPY --chown=warracker:warracker nginx.conf /etc/nginx/conf.d/default.conf.template+COPY --chown=warracker:warracker babel.cfg ./++# 2. Migration scripts and utilities+COPY --chown=warracker:warracker backend/fix_permissions.py backend/fix_permissions.sql ./+COPY --chown=warracker:warracker backend/migrations/ ./migrations/++# 3. Localization files+COPY --chown=warracker:warracker locales/ ./locales/+COPY --chown=warracker:warracker locales/ /var/www/html/locales/++# 4. Frontend (bundled in one instruction)+COPY --chown=warracker:warracker frontend/ /var/www/html/++# 5. Backend (bundled in one instruction)+COPY --chown=warracker:warracker backend/ ./backend/+COPY --chown=warracker:warracker backend/app.py backend/gunicorn_config.py ./+++# Copy configuration files and scripts from Docker directory+COPY --chown=root:root Docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf+COPY --chown=warracker:warracker Docker/entrypoint.sh /app/entrypoint.sh+COPY --chown=root:root Docker/nginx-wrapper.sh /app/nginx-wrapper.sh++# Make scripts executable+RUN chmod +x /app/entrypoint.sh /app/nginx-wrapper.sh+++# Additional environment variables+ENV PYTHONUNBUFFERED=1 \+ PYTHONDONTWRITEBYTECODE=1 \+ NGINX_MAX_BODY_SIZE_VALUE=32M++# Clean default nginx site+RUN rm -f /etc/nginx/sites-enabled/default++# Optimized health check+HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \+ CMD curl -f http://localhost/api/health 2>/dev/null || curl -f http://localhost/ || exit 1-# Install Python dependencies-COPY backend/requirements.txt .-RUN pip install --no-cache-dir -r requirements.txt--# Copy main application and config files to /app-COPY backend/app.py .-COPY backend/gunicorn_config.py .--# Create the backend package directory in /app and copy modules into it-RUN mkdir -p /app/backend-COPY backend/__init__.py /app/backend/-COPY backend/config.py /app/backend/-COPY backend/auth_utils.py /app/backend/-COPY backend/auth_routes.py /app/backend/-COPY backend/db_handler.py /app/backend/-COPY backend/extensions.py /app/backend/-COPY backend/oidc_handler.py /app/backend/-COPY backend/apprise_handler.py /app/backend/-COPY backend/notifications.py /app/backend/-COPY backend/paperless_handler.py /app/backend/-COPY backend/localization.py /app/backend/-COPY backend/warranties_routes.py /app/backend/-COPY backend/admin_routes.py /app/backend/-COPY backend/statistics_routes.py /app/backend/-COPY backend/tags_routes.py /app/backend/-COPY backend/utils.py /app/backend/-COPY backend/file_routes.py /app/backend/--# Copy other utility scripts and migrations-COPY backend/fix_permissions.py .-COPY backend/fix_permissions.sql .-COPY backend/migrations/ /app/migrations/--# Copy frontend files-COPY frontend/*.html /var/www/html/-COPY frontend/*.js /var/www/html/-COPY frontend/*.css /var/www/html/-COPY frontend/manifest.json /var/www/html/manifest.json-# Add favicon and images-COPY frontend/favicon.ico /var/www/html/-COPY frontend/img/ /var/www/html/img/-# Copy frontend JS directory for localization-COPY frontend/js/ /var/www/html/js/--# Copy localization files-COPY locales/ /app/locales/-COPY locales/ /var/www/html/locales/-COPY babel.cfg /app/--# Configure nginx site-RUN rm /etc/nginx/sites-enabled/default-# Copy nginx.conf as a template-COPY nginx.conf /etc/nginx/conf.d/default.conf.template--# Create startup script with database initialization (SUPERUSER grant removed)-RUN echo '#!/bin/bash\n\-set -e # Exit immediately if a command exits with a non-zero status.\n\-echo "Running database migrations..."\n\-python /app/migrations/apply_migrations.py\n\-echo "Running fix permissions script..."\n\-python /app/fix_permissions.py\n\-echo "Compiling translations..."\n\-cd /app && python -c "import subprocess; subprocess.run([\"pybabel\", \"compile\", \"-d\", \"locales\"], check=False)"\n\-echo "Setup script finished successfully."\n\-# The actual services (gunicorn, nginx) will be started by Supervisor below\n\-exit 0 # Exit successfully, Supervisor takes over\n\-' > /app/start.sh && chmod +x /app/start.sh--# Create a wrapper script for starting Nginx with sed for placeholder replacement-RUN echo '#!/bin/sh' > /app/start_nginx_wrapper.sh && \- echo 'set -e' >> /app/start_nginx_wrapper.sh && \- echo '' >> /app/start_nginx_wrapper.sh && \- echo '# Read the environment variable, which the user sets in docker-compose.yml' >> /app/start_nginx_wrapper.sh && \- echo 'EFFECTIVE_SIZE="${NGINX_MAX_BODY_SIZE_VALUE}"' >> /app/start_nginx_wrapper.sh && \- echo '' >> /app/start_nginx_wrapper.sh && \- echo '# Validate EFFECTIVE_SIZE or set default' >> /app/start_nginx_wrapper.sh && \- echo 'if ! echo "${EFFECTIVE_SIZE}" | grep -Eq "^[0-9]+[mMkKgG]?$"; then' >> /app/start_nginx_wrapper.sh && \- echo " echo \"Warning: NGINX_MAX_BODY_SIZE_VALUE ('\${EFFECTIVE_SIZE}') is invalid or empty. Defaulting to 32M.\"" >> /app/start_nginx_wrapper.sh && \- echo " EFFECTIVE_SIZE='32M'" >> /app/start_nginx_wrapper.sh && \- echo 'fi' >> /app/start_nginx_wrapper.sh && \- echo '' >> /app/start_nginx_wrapper.sh && \- echo '# Substitute the placeholder in the template file with the effective size' >> /app/start_nginx_wrapper.sh && \- echo '# Using | as sed delimiter to avoid issues if EFFECTIVE_SIZE somehow contained /' >> /app/start_nginx_wrapper.sh && \- echo "sed \"s|__NGINX_MAX_BODY_SIZE_CONFIG_VALUE__|\${EFFECTIVE_SIZE}|g\" /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf" >> /app/start_nginx_wrapper.sh && \- echo '' >> /app/start_nginx_wrapper.sh && \- echo "# Print the processed config for debugging" >> /app/start_nginx_wrapper.sh && \- echo "echo '--- Start of Processed Nginx default.conf ---'" >> /app/start_nginx_wrapper.sh && \- echo "cat /etc/nginx/conf.d/default.conf" >> /app/start_nginx_wrapper.sh && \- echo "echo '--- End of Processed Nginx default.conf ---'" >> /app/start_nginx_wrapper.sh && \- echo '' >> /app/start_nginx_wrapper.sh && \- echo "# Execute Nginx" >> /app/start_nginx_wrapper.sh && \- echo "exec /usr/sbin/nginx -g 'daemon off;'" >> /app/start_nginx_wrapper.sh && \- chmod +x /app/start_nginx_wrapper.sh--# REMOVED: The RUN echo command that overwrites the nginx.conf, as we now use a template.--# Expose port+# Exposed portEXPOSE 80-# Define health check-HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \- CMD curl -f http://localhost/ || exit 1--# Set environment variables-ENV PYTHONUNBUFFERED=1--# Create supervisor log directory-RUN mkdir -p /var/log/supervisor--# Create supervisor configuration-# Using Heredoc for cleaner multiline config-COPY <<EOF /etc/supervisor/conf.d/supervisord.conf-[supervisord]-nodaemon=true ; Run Supervisor in the foreground-user=root ; Run Supervisor as root-logfile=/dev/stdout ; Log Supervisor messages to stdout-logfile_maxbytes=0 ; Disable log rotation for stdout-pidfile=/var/run/supervisord.pid--; Program for initial setup (migrations, permissions)-; Runs once at the start-[program:setup]-command=/app/start.sh ; Execute the setup script-directory=/app-autostart=true-autorestart=false ; Do not restart if it finishes-startsecs=0 ; Start immediately-startretries=1 ; Only retry once if it fails immediately-exitcodes=0 ; Expected exit code is 0-stdout_logfile=/dev/stdout ; Log stdout to container stdout-stdout_logfile_maxbytes=0-stderr_logfile=/dev/stderr ; Log stderr to container stderr-stderr_logfile_maxbytes=0-priority=5 ; Run before nginx and gunicorn--[program:nginx]-# Command now executes the wrapper script-command=/app/start_nginx_wrapper.sh-autostart=true-autorestart=true ; Restart nginx if it crashes-startsecs=5 ; Give setup some time before starting nginx-startretries=5-stdout_logfile=/dev/stdout ; Log stdout to container stdout-stdout_logfile_maxbytes=0-stderr_logfile=/dev/stderr ; Log stderr to container stderr-stderr_logfile_maxbytes=0-priority=10 ; Start after setup--[program:gunicorn]-command=gunicorn --config /app/gunicorn_config.py "backend:create_app()" ; Start Gunicorn with Application Factory-directory=/app-autostart=true-autorestart=true ; Restart Gunicorn if it crashes-startsecs=5 ; Give setup some time before starting gunicorn-startretries=5-stdout_logfile=/dev/stdout ; Log stdout to container stdout-stdout_logfile_maxbytes=0-stderr_logfile=/dev/stderr ; Log stderr to container stderr-stderr_logfile_maxbytes=0-priority=20 ; Start after setup-stopsignal=QUIT ; Graceful shutdown signal for Gunicorn-stopwaitsecs=10 ; Wait up to 10 seconds for graceful shutdown-killasgroup=true ; Ensure all gunicorn processes are killed-stopasgroup=true ; Ensure all gunicorn processes receive the stop signal-EOF--# Start supervisor which will manage the setup, nginx, and gunicorn processes+# Entry point and command+# ENTRYPOINT runs setup tasks then executes supervisor+# Supervisor needs to run as root to manage services with different users+ENTRYPOINT ["/app/entrypoint.sh"]CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]diff --git a/backend/oidc_handler.py b/backend/oidc_handler.pyindex 7f2f0a8..a740c0d 100644--- a/backend/oidc_handler.py+++ b/backend/oidc_handler.py@@ -7,12 +7,12 @@ from flask import Blueprint, jsonify, redirect, url_for, current_app, request, s# Import shared extensions and utilitiestry:# Try relative imports (when modules are in same directory)- from .extensions import oauth+ from .extensions import oauthfrom .db_handler import get_db_connection, release_db_connectionfrom .auth_utils import generate_tokenexcept ImportError:# Fallback to direct imports- from extensions import oauth+ from extensions import oauthfrom db_handler import get_db_connection, release_db_connectionfrom auth_utils import generate_token@@ -35,7 +35,11 @@ def init_oidc_client(current_app_instance, db_conn_func, db_release_func):cur.execute("SELECT key, value FROM site_settings WHERE key LIKE 'oidc_%%'")for row in cur.fetchall():oidc_db_settings[row[0]] = row[1]- logger.info(f"[FACTORY OIDC_INIT] Fetched OIDC settings from DB: {oidc_db_settings}")++ # Mask sensitive values for logging (inline, no external dependency)+ safe_settings = {k: ('***REDACTED***' if 'secret' in k.lower() or 'password' in k.lower() or 'token' in k.lower() else v)+ for k, v in oidc_db_settings.items()}+ logger.info(f"[FACTORY OIDC_INIT] Fetched OIDC settings from DB: {safe_settings}")else:logger.error("[FACTORY OIDC_INIT] Database connection failed, cannot fetch OIDC settings from DB.")except Exception as e:@@ -72,6 +76,7 @@ def init_oidc_client(current_app_instance, db_conn_func, db_release_func):if client_id and client_secret and issuer_url:logger.info(f"[FACTORY OIDC_INIT] Registering OIDC client '{provider_name}' with Authlib.")+oauth.register(name=provider_name,client_id=client_id,@@ -101,12 +106,12 @@ def oidc_login_route():return jsonify({'message': 'OIDC provider not configured correctly.'}), 500# Corrected url_for to use blueprint name- redirect_uri = url_for('oidc.oidc_callback_route', _external=True)-+ redirect_uri = url_for('oidc.oidc_callback_route', _external=True)+# HTTPS check for productionif os.environ.get('FLASK_ENV') == 'production' and not redirect_uri.startswith('https'):redirect_uri = redirect_uri.replace('http://', 'https://', 1)-+logger.info(f"[OIDC_HANDLER] /oidc/login redirect_uri: {redirect_uri}")return oauth.create_client(oidc_provider_name).authorize_redirect(redirect_uri)@@ -122,7 +127,7 @@ def oidc_callback_route():logger.error("[OIDC_HANDLER] OIDC provider name not configured for callback.")frontend_login_url = os.environ.get('FRONTEND_URL', current_app.config.get('APP_BASE_URL', 'http://localhost:8080')).rstrip('/') + "/login.html"return redirect(f"{frontend_login_url}?oidc_error=oidc_misconfigured")-+client = oauth.create_client(oidc_provider_name)try:token_data = client.authorize_access_token()@@ -148,7 +153,7 @@ def oidc_callback_route():logger.error(f"[OIDC_HANDLER] OIDC callback error fetching userinfo: {e}")frontend_login_url = os.environ.get('FRONTEND_URL', 'http://localhost:8080').rstrip('/') + "/login.html"return redirect(f"{frontend_login_url}?oidc_error=userinfo_fetch_failed")-+if not userinfo:logger.error("[OIDC_HANDLER] OIDC callback: Failed to retrieve userinfo.")frontend_login_url = os.environ.get('FRONTEND_URL', 'http://localhost:8080').rstrip('/') + "/login.html"@@ -180,7 +185,7 @@ def oidc_callback_route():cur.execute("SELECT id, username, email, first_name, last_name, is_admin FROM users WHERE oidc_sub = %s AND oidc_issuer = %s AND is_active = TRUE",(oidc_subject, oidc_issuer))user_db_data = cur.fetchone()-+user_id = Noneis_new_user = False@@ -214,31 +219,31 @@ def oidc_callback_route():# Check if registration is enabled before creating new userscur.execute("""SELECT EXISTS (- SELECT FROM information_schema.tables+ SELECT FROM information_schema.tablesWHERE table_name = 'site_settings')""")table_exists = cur.fetchone()[0]-+registration_enabled = Trueif table_exists:# Get registration_enabled settingcur.execute("SELECT value FROM site_settings WHERE key = 'registration_enabled'")result = cur.fetchone()-+if result:registration_enabled = result[0].lower() == 'true'-+# Check if there are any users (first user can register regardless of setting)cur.execute('SELECT COUNT(*) FROM users')user_count = cur.fetchone()[0]-+# If registration is disabled and this is not the first user, deny SSO signupif not registration_enabled and user_count > 0:logger.warning(f"[OIDC_HANDLER] New OIDC user registration denied - registrations are disabled. Subject: {oidc_subject}")frontend_login_url = os.environ.get('FRONTEND_URL', current_app.config.get('APP_BASE_URL', 'http://localhost:8080')).rstrip('/') + "/login.html"return redirect(f"{frontend_login_url}?oidc_error=registration_disabled")-+# New user provisioningis_new_user = Trueif not email:@@ -289,26 +294,26 @@ def oidc_callback_route():# Insert new OIDC usercur.execute(- """INSERT INTO users (username, email, first_name, last_name, is_admin, oidc_sub, oidc_issuer, is_active)+ """INSERT INTO users (username, email, first_name, last_name, is_admin, oidc_sub, oidc_issuer, is_active)VALUES (%s, %s, %s, %s, %s, %s, %s, TRUE) RETURNING id""",(username, email, first_name, last_name, is_admin, oidc_subject, oidc_issuer))user_id = cur.fetchone()[0]logger.info(f"[OIDC_HANDLER] New OIDC user created with ID {user_id} for sub {oidc_subject}")-+if user_id:app_session_token = generate_token(user_id) # Generate app-specific JWT-+# Update last login timestampcur.execute('UPDATE users SET last_login = %s WHERE id = %s', (datetime.now(UTC), user_id))-+# Log OIDC session in user_sessions tableip_address = request.remote_addruser_agent = request.headers.get('User-Agent', '')# Use a different UUID for session_token in DB if needed, or re-use app_session_token if appropriate for your session model- db_session_token = str(uuid.uuid4())+ db_session_token = str(uuid.uuid4())expires_at = datetime.now(UTC) + current_app.config['JWT_EXPIRATION_DELTA']-+cur.execute('INSERT INTO user_sessions (user_id, session_token, expires_at, ip_address, user_agent, login_method) VALUES (%s, %s, %s, %s, %s, %s)',(user_id, db_session_token, expires_at, ip_address, user_agent, 'oidc')@@ -319,7 +324,7 @@ def oidc_callback_route():redirect_target = f"{frontend_url}/auth-redirect.html?token={app_session_token}"if is_new_user:redirect_target += "&new_user=true"-+logger.info(f"[OIDC_HANDLER] /oidc/callback redirecting to frontend: {redirect_target}")return redirect(redirect_target)else:@@ -344,24 +349,24 @@ def get_oidc_status_route():# Get OIDC settings including the new oidc_only_modecur.execute("SELECT key, value FROM site_settings WHERE key IN ('oidc_enabled', 'oidc_only_mode', 'oidc_provider_name')")settings = {row[0]: row[1] for row in cur.fetchall()}-+# Apply same precedence logic as init_oidc_client()# Priority: Environment Variable > Database Setting > Hardcoded Default-+# Check OIDC enabled status with correct precedenceoidc_enabled_from_env = os.environ.get('OIDC_ENABLED')if oidc_enabled_from_env is not None:oidc_is_enabled = oidc_enabled_from_env.lower() == 'true'else:oidc_is_enabled = settings.get('oidc_enabled', 'false').lower() == 'true'-+# Check OIDC only mode with correct precedenceoidc_only_mode_from_env = os.environ.get('OIDC_ONLY_MODE')if oidc_only_mode_from_env is not None:oidc_only_mode = oidc_only_mode_from_env.lower() == 'true'else:oidc_only_mode = settings.get('oidc_only_mode', 'false').lower() == 'true'-+# Check provider name with correct precedenceoidc_provider_name_from_env = os.environ.get('OIDC_PROVIDER_NAME')if oidc_provider_name_from_env is not None:@@ -381,7 +386,7 @@ def get_oidc_status_route():oidc_enabled_from_env = os.environ.get('OIDC_ENABLED')oidc_only_mode_from_env = os.environ.get('OIDC_ONLY_MODE')oidc_provider_name_from_env = os.environ.get('OIDC_PROVIDER_NAME')-+return jsonify({"oidc_enabled": oidc_enabled_from_env.lower() == 'true' if oidc_enabled_from_env else False,"oidc_only_mode": oidc_only_mode_from_env.lower() == 'true' if oidc_only_mode_from_env else False,diff --git a/backend/requirements.txt b/backend/requirements.txtindex 641edc1..0cd8f49 100644--- a/backend/requirements.txt+++ b/backend/requirements.txt@@ -1,6 +1,6 @@Flask==3.0.3gunicorn==23.0.0-psycopg2==2.9.9+psycopg2==2.9.10Werkzeug==3.0.3flask-cors==4.0.1Flask-Login==0.6.3@@ -11,7 +11,7 @@ APScheduler==3.10.4python-dateutil==2.9.0Authlib==1.3.1requests==2.32.3-gevent==24.2.1+gevent==24.10.1setuptools<81apprise==1.9.3Flask-Babel==4.0.0