Added ProxyFix to force HTTPS OAuth redirects in cloud
Browse files
wsgi.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
from collections import deque
|
|
|
|
| 4 |
|
| 5 |
# Allow OAuth over HTTP for local testing
|
| 6 |
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
|
|
@@ -16,9 +17,12 @@ def handle_connect():
|
|
| 16 |
print(" [+] Client connected to Live Feed")
|
| 17 |
|
| 18 |
# --- CLOUD TOGGLE (THE FORCE FIELD) ---
|
| 19 |
-
# Hugging Face sets SPACE_ID. If this exists, we are in the cloud.
|
| 20 |
IS_CLOUD = os.environ.get('SPACE_ID') is not None
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# ONLY import Scapy and Network Monitor if running locally
|
| 23 |
if not IS_CLOUD:
|
| 24 |
try:
|
|
@@ -40,13 +44,11 @@ if __name__ == '__main__':
|
|
| 40 |
print("--- WEBPASS SECURITY SERVER STARTING ---")
|
| 41 |
|
| 42 |
if not IS_CLOUD:
|
| 43 |
-
# LOCAL MODE: Run the packet sniffer!
|
| 44 |
target_interface = get_best_interface()
|
| 45 |
if target_interface:
|
| 46 |
print(f" [+] Launching Packet Sniffer on: {target_interface}")
|
| 47 |
start_packet_capture(app, socketio, interface=target_interface)
|
| 48 |
else:
|
| 49 |
-
# CLOUD MODE: Keep the sniffer turned off
|
| 50 |
print(" [*] Running in Cloud Mode. Hardware packet sniffing is disabled.")
|
| 51 |
|
| 52 |
print(" [+] Server running on http://127.0.0.1:5000")
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
from collections import deque
|
| 4 |
+
from werkzeug.middleware.proxy_fix import ProxyFix # <--- NEW IMPORT
|
| 5 |
|
| 6 |
# Allow OAuth over HTTP for local testing
|
| 7 |
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
|
|
|
|
| 17 |
print(" [+] Client connected to Live Feed")
|
| 18 |
|
| 19 |
# --- CLOUD TOGGLE (THE FORCE FIELD) ---
|
|
|
|
| 20 |
IS_CLOUD = os.environ.get('SPACE_ID') is not None
|
| 21 |
|
| 22 |
+
if IS_CLOUD:
|
| 23 |
+
# Tell Flask it is behind a secure Cloud Proxy (Forces HTTPS for Google OAuth)
|
| 24 |
+
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
| 25 |
+
|
| 26 |
# ONLY import Scapy and Network Monitor if running locally
|
| 27 |
if not IS_CLOUD:
|
| 28 |
try:
|
|
|
|
| 44 |
print("--- WEBPASS SECURITY SERVER STARTING ---")
|
| 45 |
|
| 46 |
if not IS_CLOUD:
|
|
|
|
| 47 |
target_interface = get_best_interface()
|
| 48 |
if target_interface:
|
| 49 |
print(f" [+] Launching Packet Sniffer on: {target_interface}")
|
| 50 |
start_packet_capture(app, socketio, interface=target_interface)
|
| 51 |
else:
|
|
|
|
| 52 |
print(" [*] Running in Cloud Mode. Hardware packet sniffing is disabled.")
|
| 53 |
|
| 54 |
print(" [+] Server running on http://127.0.0.1:5000")
|