arthurcornelio88 commited on
Commit
14668d2
·
1 Parent(s): 91aca8d

csfr_fix.py added

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -0
  2. scripts/csrf_fix.py +13 -0
  3. start.sh +3 -0
Dockerfile CHANGED
@@ -37,6 +37,7 @@ RUN pip install --no-cache-dir -r /opt/airflow/requirements.txt
37
  # Copy DAGs and the startup script
38
  COPY --chown=airflow:airflow ./dags /opt/airflow/dags
39
  COPY --chown=airflow:airflow start.sh /opt/airflow/start.sh
 
40
  RUN chmod +x /opt/airflow/start.sh
41
 
42
  # Switch back to airflow user for security
 
37
  # Copy DAGs and the startup script
38
  COPY --chown=airflow:airflow ./dags /opt/airflow/dags
39
  COPY --chown=airflow:airflow start.sh /opt/airflow/start.sh
40
+ COPY --chown=airflow:airflow ./scripts/csfr_fix.py /opt/airflow/csfr_fix.py
41
  RUN chmod +x /opt/airflow/start.sh
42
 
43
  # Switch back to airflow user for security
scripts/csrf_fix.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import request, g, session
2
+ from airflow.www.app import cached_app
3
+
4
+ def csrf_injection_middleware():
5
+ """Middleware pour forcer le token CSRF dans les requêtes Flask"""
6
+ app = cached_app(config=None)
7
+ @app.before_request
8
+ def add_csrf_token():
9
+ if 'csrf_token' in session:
10
+ g.csrf_token = session['csrf_token']
11
+ request.headers['X-CSRF-Token'] = session['csrf_token']
12
+
13
+ return app
start.sh CHANGED
@@ -129,6 +129,9 @@ for VAR in "${REQUIRED_VARS[@]}"; do
129
  log "✅ $VAR is set."
130
  done
131
 
 
 
 
132
  ### 🚀 Start Airflow Services
133
  log "🚀 Starting Airflow services..."
134
  airflow scheduler > /dev/null 2>&1 &
 
129
  log "✅ $VAR is set."
130
  done
131
 
132
+ python /opt/airflow/csrf_fix.py &
133
+ log "✅ CSRF fix applied."
134
+
135
  ### 🚀 Start Airflow Services
136
  log "🚀 Starting Airflow services..."
137
  airflow scheduler > /dev/null 2>&1 &