Skip to content

Commit

Permalink
DI app instance
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAndrewJackson committed Sep 15, 2023
1 parent 9bc91bc commit 2b8b7f1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from sqlalchemy.engine import Connection, ResultProxy
from sqlalchemy.sql.elements import TextClause


# revision identifiers, used by Alembic.
from fides.api.models.sql_models import DataUse

Expand Down
5 changes: 3 additions & 2 deletions src/fides/api/api/v1/endpoints/config_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, Optional

from fastapi import Depends
from fastapi import Depends, Request
from fastapi.params import Security
from loguru import logger
from sqlalchemy.orm import Session
Expand Down Expand Up @@ -49,6 +49,7 @@ def get_config(
def update_settings(
*,
db: Session = Depends(deps.get_db),
request: Request,
data: ApplicationConfigSchema,
) -> ApplicationConfigSchema:
"""
Expand All @@ -66,7 +67,7 @@ def update_settings(
"security" in pruned_data.keys()
and "cors_origins" in pruned_data.get("security").keys()
):
load_updated_cors_domains(pruned_data["security"]["cors_origins"])
load_updated_cors_domains(pruned_data["security"]["cors_origins"], request.app)

return update_config.api_set

Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async def setup_server() -> None:

db = get_api_session()
config_proxy = ConfigProxy(db)
load_updated_cors_domains(config_proxy.security.cors_origins)
load_updated_cors_domains(config_proxy.security.cors_origins, app)

check_redis()

Expand Down
7 changes: 4 additions & 3 deletions src/fides/config/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import getenv
from typing import List

from fastapi.applications import FastAPI
from starlette.middleware.cors import CORSMiddleware

DEFAULT_CONFIG_PATH = ".fides/fides.toml"
Expand Down Expand Up @@ -86,9 +87,9 @@ def get_dev_mode() -> bool:
}


def load_updated_cors_domains(domains: List[str], resetDomains=False) -> None:
from fides.api.main import app

def load_updated_cors_domains(
domains: List[str], app: FastAPI, resetDomains=False
) -> None:
for mw in app.user_middleware:
if mw.cls is CORSMiddleware:
if resetDomains:
Expand Down

0 comments on commit 2b8b7f1

Please sign in to comment.