flock-core 0.4.515__py3-none-any.whl → 0.4.516__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flock-core might be problematic. Click here for more details.

flock/webapp/app/main.py CHANGED
@@ -27,6 +27,70 @@ from fastapi.staticfiles import StaticFiles
27
27
  from fastapi.templating import Jinja2Templates
28
28
  from pydantic import BaseModel
29
29
 
30
+ # Custom middleware for handling proxy headers
31
+ # from starlette.middleware.base import BaseHTTPMiddleware
32
+ # from starlette.requests import Request as StarletteRequest
33
+ from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
34
+
35
+ # class ProxyHeadersMiddleware(BaseHTTPMiddleware):
36
+ # """Middleware to handle proxy headers for HTTPS detection.
37
+ # This ensures url_for() generates HTTPS URLs when behind an HTTPS proxy.
38
+ # """
39
+ # async def dispatch(self, request: StarletteRequest, call_next):
40
+ # import logging
41
+ # logger = logging.getLogger(__name__)
42
+ # # Log original scheme and relevant headers for debugging
43
+ # original_scheme = request.scope.get("scheme", "unknown")
44
+ # logger.debug(f"Original scheme: {original_scheme}, URL: {request.url}")
45
+ # # Check for common proxy headers that indicate HTTPS
46
+ # forwarded_proto = request.headers.get("x-forwarded-proto")
47
+ # forwarded_scheme = request.headers.get("x-forwarded-scheme")
48
+ # cloudflare_proto = request.headers.get("cf-visitor")
49
+ # # Log proxy headers for debugging
50
+ # proxy_headers = {
51
+ # "x-forwarded-proto": forwarded_proto,
52
+ # "x-forwarded-scheme": forwarded_scheme,
53
+ # "cf-visitor": cloudflare_proto,
54
+ # "x-forwarded-for": request.headers.get("x-forwarded-for"),
55
+ # "host": request.headers.get("host")
56
+ # }
57
+ # logger.debug(f"Proxy headers: {proxy_headers}")
58
+ # scheme_updated = False
59
+ # # Handle X-Forwarded-Proto header
60
+ # if forwarded_proto:
61
+ # # Update the request scope to reflect the original protocol
62
+ # request.scope["scheme"] = forwarded_proto.lower()
63
+ # scheme_updated = True
64
+ # logger.debug(f"Updated scheme from X-Forwarded-Proto: {forwarded_proto}")
65
+ # # Handle X-Forwarded-Scheme header
66
+ # elif forwarded_scheme:
67
+ # request.scope["scheme"] = forwarded_scheme.lower()
68
+ # scheme_updated = True
69
+ # logger.debug(f"Updated scheme from X-Forwarded-Scheme: {forwarded_scheme}")
70
+ # # Handle Cloudflare's CF-Visitor header (JSON format)
71
+ # elif cloudflare_proto:
72
+ # try:
73
+ # import json
74
+ # visitor_info = json.loads(cloudflare_proto)
75
+ # if visitor_info.get("scheme"):
76
+ # request.scope["scheme"] = visitor_info["scheme"].lower()
77
+ # scheme_updated = True
78
+ # logger.debug(f"Updated scheme from CF-Visitor: {visitor_info['scheme']}")
79
+ # except (json.JSONDecodeError, KeyError) as e:
80
+ # logger.warning(f"Failed to parse CF-Visitor header: {e}")
81
+ # if not scheme_updated:
82
+ # logger.debug("No proxy headers found, keeping original scheme")
83
+ # # Handle X-Forwarded-For for client IP (optional but good practice)
84
+ # forwarded_for = request.headers.get("x-forwarded-for")
85
+ # if forwarded_for:
86
+ # # Take the first IP in the chain (the original client)
87
+ # client_ip = forwarded_for.split(",")[0].strip()
88
+ # request.scope["client"] = (client_ip, request.scope.get("client", ["", 0])[1])
89
+ # # Log final scheme
90
+ # final_scheme = request.scope.get("scheme")
91
+ # logger.debug(f"Final scheme: {final_scheme}")
92
+ # response = await call_next(request)
93
+ # return response
30
94
  from flock.core.api.endpoints import create_api_router
31
95
  from flock.core.api.run_store import RunStore
32
96
 
@@ -293,7 +357,11 @@ async def lifespan(app: FastAPI):
293
357
 
294
358
  app = FastAPI(title="Flock Web UI & API", lifespan=lifespan, docs_url="/docs",
295
359
  openapi_url="/openapi.json", root_path=os.getenv("FLOCK_ROOT_PATH", ""))
296
- logger.info("FastAPI booting complete.")
360
+
361
+ # Add middleware for handling proxy headers (HTTPS detection)
362
+ app.add_middleware(ProxyHeadersMiddleware)
363
+ logger.info("FastAPI booting complete with proxy headers middleware.")
364
+
297
365
  BASE_DIR = Path(__file__).resolve().parent.parent
298
366
  app.mount("/static", StaticFiles(directory=str(BASE_DIR / "static")), name="static")
299
367
  templates = Jinja2Templates(directory=str(BASE_DIR / "templates"))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flock-core
3
- Version: 0.4.515
3
+ Version: 0.4.516
4
4
  Summary: Declarative LLM Orchestration at Scale
5
5
  Author-email: Andre Ratzenberger <andre.ratzenberger@whiteduck.de>
6
6
  License-File: LICENSE
@@ -495,7 +495,7 @@ flock/webapp/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
495
495
  flock/webapp/app/chat.py,sha256=d5a_mr3H2nuWNFSpSlI_HyqX-J_4krndd4A-8S25EKM,28679
496
496
  flock/webapp/app/config.py,sha256=lqmneujnNZk-EFJV5cWpvxkqisxH3T3zT_YOI0JYThE,4809
497
497
  flock/webapp/app/dependencies.py,sha256=JUcwY1N6SZplU141lMN2wk9dOC9er5HCedrKTJN9wJk,5533
498
- flock/webapp/app/main.py,sha256=54DHCA4jaOBrW3Lly0t-r_gSOEBj96G4Izt5pkbFZSw,57142
498
+ flock/webapp/app/main.py,sha256=9wRxzahWhD8fFjByyvMhJOjsll7u4GnW2peGw2DXgPE,60727
499
499
  flock/webapp/app/models_ui.py,sha256=vrEBLbhEp6FziAgBSFOLT1M7ckwadsTdT7qus5_NduE,329
500
500
  flock/webapp/app/theme_mapper.py,sha256=QzWwLWpED78oYp3FjZ9zxv1KxCyj43m8MZ0fhfzz37w,34302
501
501
  flock/webapp/app/utils.py,sha256=RF8DMKKAj1XPmm4txUdo2OdswI1ATQ7cqUm6G9JFDzA,2942
@@ -561,8 +561,8 @@ flock/workflow/agent_execution_activity.py,sha256=Gy6FtuVAjf0NiUXmC3syS2eJpNQF4R
561
561
  flock/workflow/flock_workflow.py,sha256=iSUF_soFvWar0ffpkzE4irkDZRx0p4HnwmEBi_Ne2sY,9666
562
562
  flock/workflow/temporal_config.py,sha256=3_8O7SDEjMsSMXsWJBfnb6XTp0TFaz39uyzSlMTSF_I,3988
563
563
  flock/workflow/temporal_setup.py,sha256=YIHnSBntzOchHfMSh8hoLeNXrz3B1UbR14YrR6soM7A,1606
564
- flock_core-0.4.515.dist-info/METADATA,sha256=7nfOA03KGxxfxZ5-sm_GuTHXqhhD1NRxo_hvp6d8zBI,22786
565
- flock_core-0.4.515.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
566
- flock_core-0.4.515.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
567
- flock_core-0.4.515.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
568
- flock_core-0.4.515.dist-info/RECORD,,
564
+ flock_core-0.4.516.dist-info/METADATA,sha256=FsymlwNMAW5sjRvcs_PIRsIbL1w484HIeYIsMGrucx0,22786
565
+ flock_core-0.4.516.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
566
+ flock_core-0.4.516.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
567
+ flock_core-0.4.516.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
568
+ flock_core-0.4.516.dist-info/RECORD,,