Skip to content

Commit

Permalink
start cleanning
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Nov 1, 2024
1 parent 20cf6b7 commit fe46b9c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions production/api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from redis_client import redis_factory_get, RedisClient
from http_service import http_service_factory_get, HttpService
import msgpack
from oidc.authentication_middleware import authentication_middleware
from oidc.authentication import XHttpServiceGet
app = FastAPI()

# Ajouter le middleware CORS
Expand All @@ -24,6 +26,17 @@
allow_headers=["*"],
)

app_settings = app_settings_factory_get()
if app_settings.oidc_enable == "true":
exclude_urls = ["/health", "/version", "/metrics", "/docs", "/openapi_json"]
app.add_middleware(authentication_middleware(
app_settings.oidc_authority,
["api"],
"api",
exclude_urls,
XHttpServiceGet(http_service_factory_get().get_http_async_client())
))

# Stocker les messages SSE par client
clients = {}

Expand Down Expand Up @@ -133,17 +146,5 @@ async def health():

if __name__ == "__main__":
import uvicorn
from oidc.authentication_middleware import authentication_middleware
from oidc.authentication import XHttpServiceGet

app_settings = app_settings_factory_get()
if app_settings.oidc_enable == "true":
exclude_urls = ["/health", "/version", "/metrics", "/docs", "/openapi_json"]
app.add_middleware(authentication_middleware(
app_settings.oidc_authority,
["api"],
"api",
exclude_urls,
XHttpServiceGet(http_service_factory_get().get_http_async_client())
))

uvicorn.run(app, host=app_settings.server_host, port=app_settings.server_port)

0 comments on commit fe46b9c

Please sign in to comment.