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

Added security headers library for fastApi #198

Merged
merged 6 commits into from
Sep 12, 2023
Merged

Added security headers library for fastApi #198

merged 6 commits into from
Sep 12, 2023

Conversation

wooferclaw
Copy link
Collaborator

Security fix for HSTS issue. Not yet tested.

@jimmymathews
Copy link
Collaborator

It looks ok, but let's add at least 1 test that the secure library is doing what we expect.
This can be a test in e.g. test/apiserver/unit_tests/ that does a handful of requests and inspects the headers. We can "pin" the expected headers with assertions of exact contents, then we will possibly know if the secure library is changing anything on us in the future or is injecting some vulnerability.

@jimmymathews
Copy link
Collaborator

I added a minimal test of the headers for one simple endpoint. The test just checks that the response headers are equal to a certain list. If this changes in future test runs we will know that the secure library is acting differently.

The headers as reported by curl:

< HTTP/1.1 200 OK
< server: uvicorn
< content-length: 97
< content-type: application/json
< strict-transport-security: max-age=63072000; includeSubdomains
< x-frame-options: SAMEORIGIN
< x-xss-protection: 0
< x-content-type-options: nosniff
< referrer-policy: no-referrer, strict-origin-when-cross-origin
< cache-control: no-store
< 
{ [97 bytes data]
* Connection #0 to host spt-apiserver-testing left intact
[{"handle":"Melanoma intralesional IL2","display_name_detail":"Cancer Immunology Research 2022"}]

@jimmymathews
Copy link
Collaborator

All test pass so I am merging.

@jimmymathews jimmymathews merged commit 93a8be3 into main Sep 12, 2023
1 check 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