Skip to content

Commit

Permalink
fix: added csrf origins for production environments
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvanr committed Aug 29, 2023
1 parent c017ebf commit 365a4b4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .env.example.docker
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ MONGO_CONNECTION_STRING=mongodb://admin_example:exampl3_123!@mongo:27017

# NGINX HOST, localhost for local development, iati.cloud for production
IC_DOMAIN=localhost

# Source of incoming requests and access to Django admin, for example in production: "https://datastore.iati.cloud"
CSRF_TRUSTED_ORIGINS=https://<your_domain>
3 changes: 3 additions & 0 deletions .env.example.local
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ MONGO_CONNECTION_STRING=mongodb://admin_example:exampl3_123!@localhost:27017

# NGINX HOST, localhost for local development, iati.cloud for production
IC_DOMAIN=localhost

# Source of incoming requests and access to Django admin, for example in production: "https://datastore.iati.cloud"
CSRF_TRUSTED_ORIGINS=https://<your_domain>
2 changes: 1 addition & 1 deletion direct_indexing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def fcdo_replace_partial_url(find_url, replace_url):
logging.info("fcdo_replace_partial_url:: update dataset_metadata file")
path = f'{settings.DATASET_PARENT_PATH}/dataset_metadata.json'
with open(path, 'w') as file:
json.dump(dataset_metadata, file)
json.dump(dataset_metadata, file, indent=4)

# run the dataset metadata with update = True and force_update = True
# this will automatically all the files that have a new URL and a new HASH
Expand Down
3 changes: 3 additions & 0 deletions iaticloud/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,6 @@ def env_bool(var_name, default='False'):

# # Fresh dataset
FRESH = env_bool('FRESH', 'True')

# Origins for production
CSRF_TRUSTED_ORIGINS = [os.getenv('CSRF_TRUSTED_ORIGINS'), 'http://localhost/']

0 comments on commit 365a4b4

Please sign in to comment.