Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add various HTTP headers to improve security #643

Merged
merged 9 commits into from
Oct 13, 2024

Conversation

Andrew-Dickinson
Copy link
Member

Improve our security by following the HTTP header recommendations from the following resources:

Setting X-Forwarded-Proto also fixes a bug which caused a mixed content error on the changes from #636, since it fixes the value Django uses for request.scheme (currently set to http in prod due to the reverse proxy)

src/meshdb/settings.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.18%. Comparing base (28649c1) to head (c08c817).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #643   +/-   ##
=======================================
  Coverage   94.18%   94.18%           
=======================================
  Files          80       80           
  Lines        3251     3251           
=======================================
  Hits         3062     3062           
  Misses        189      189           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

]
CSP_REPORT_URI = [
"https://csp-report.browser-intake-datadoghq.com/api/v2/logs"
"?dd-api-key=pubca00a94e49167539d2e291bea2b0f20f&dd-evp-origin=content-security-policy"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this naughty? We give it out for free to anyone who hits the site so having it in code seems fine?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify correct type and limited access

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely a client token, from the docs we are definitely using it correctly:

For security reasons, API keys cannot be used to send data from a browser, mobile, or TV app, as they would be exposed client-side. Instead, end user facing applications use client tokens to send data to Datadog.

I can't find any knobs to turn for the permissions on the token, and nothing is mentioned in the docs about this. I think client tokens are inherently limited to only specific things (probably to prevent footguns)

src/meshdb/settings.py Outdated Show resolved Hide resolved
src/meshdb/settings.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@james-otten james-otten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff. Thank you for doing this!

@Andrew-Dickinson Andrew-Dickinson enabled auto-merge (squash) October 13, 2024 22:32
@Andrew-Dickinson Andrew-Dickinson merged commit 85cbbd4 into main Oct 13, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants