Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Configurable cors #791

Merged
merged 9 commits into from
Apr 30, 2022
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ FLASK_DEBUG=0
FLASK_RUN_PORT=5000
SECRET_KEY="t8GIEp8hWmR8y6VLqd6qQCMXzjRaKsx8nRruWNtFuec="
SEND_FILE_MAX_AGE_DEFAULT=31556926
CORS_ENABLED=False

### Database Configuration
DB_HOST=chaosgenius-db
Expand Down
9 changes: 8 additions & 1 deletion chaos_genius/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ def create_app(config_object="chaos_genius.settings"):
register_shellcontext(app)
register_commands(app)
configure_logger(app)
CORS(app) # TODO: Remove the CORS in v1 release
configure_cors(app)
return app


def configure_cors(app):
"""Configure cross origin request sharing."""
if app.config["CORS_ENABLED"]:
CORS(app)
return None


def register_extensions(app):
"""Register Flask extensions."""
bcrypt.init_app(app)
Expand Down
1 change: 1 addition & 0 deletions chaos_genius/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _make_bool(val: Union[str, bool]) -> bool:
CELERY_RESULT_BACKEND = os.getenv('CELERY_RESULT_BACKEND')
CELERY_BROKER_URL = os.getenv('CELERY_BROKER_URL')
CHAOSGENIUS_WEBAPP_URL = os.getenv("CHAOSGENIUS_WEBAPP_URL")
CORS_ENABLED = _make_bool(os.getenv("CORS_ENABLED", default=False))

EMAIL_HOST = os.getenv('EMAIL_HOST')
EMAIL_HOST_PORT = os.getenv('EMAIL_HOST_PORT', default=587)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev-thirdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}

chaosgenius-webapp:
container_name: chaosgenius-webapp
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}

chaosgenius-webapp:
container_name: chaosgenius-webapp
Expand Down
1 change: 1 addition & 0 deletions docker-compose.fluentd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}
logging: *default-logging

chaosgenius-webapp:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.latest-thirdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}

chaosgenius-webapp:
container_name: chaosgenius-webapp
Expand Down
1 change: 1 addition & 0 deletions docker-compose.latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}

chaosgenius-webapp:
container_name: chaosgenius-webapp
Expand Down
1 change: 1 addition & 0 deletions docker-compose.thirdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}

chaosgenius-webapp:
container_name: chaosgenius-webapp
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
- CHAOSGENIUS_ENTERPRISE_EDITION_KEY=${CHAOSGENIUS_ENTERPRISE_EDITION_KEY}
- CHAOSGENIUS_WEBAPP_URL=${CHAOSGENIUS_WEBAPP_URL}
- CORS_ENABLED=${CORS_ENABLED}

chaosgenius-webapp:
container_name: chaosgenius-webapp
Expand Down