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

[ENH] Add environment variable for allowed origins for CORS #151

Merged
merged 18 commits into from
Aug 31, 2023

Conversation

alyssadai
Copy link
Contributor

@alyssadai alyssadai commented Aug 29, 2023

Closes #150

Changes proposed in this pull request:

  • New environment variable NB_API_ALLOWED_ORIGINS replaces hard-coded wildcard allowing all origins for CORS
    • default value is an empty string
  • Add utility function to parse origins into a list
  • Raise warning if no allowed origins are specified
  • Tests added that specified origins are parsed correctly + warning raised appropriately

Checklist

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see https://neurobagel.org/contributing/pull_requests for more info)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

@alyssadai alyssadai marked this pull request as draft August 29, 2023 20:42
@alyssadai alyssadai marked this pull request as ready for review August 29, 2023 21:08
@coveralls
Copy link
Collaborator

coveralls commented Aug 29, 2023

Pull Request Test Coverage Report for Build 6039803111

  • 30 of 30 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 6016853072: 0.0%
Covered Lines: 368
Relevant Lines: 368

💛 - Coveralls

@alyssadai alyssadai changed the title Add environment variable for allowed origins for CORS [ENH] Add environment variable for allowed origins for CORS Aug 29, 2023
@surchs surchs self-requested a review August 30, 2023 14:35
Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

Thanks for this PR @alyssadai. Everything functional is looking good! I still requested changes to make sure we communicate our expectations for CORS clearly to the user - I left some minor comments on where I think we should clarify things.

Take a look and let me know what you think. Then I think this can go

README.md Outdated Show resolved Hide resolved
app/api/utility.py Outdated Show resolved Hide resolved
tests/test_query.py Show resolved Hide resolved
app/api/utility.py Show resolved Hide resolved
app/main.py Show resolved Hide resolved
.template-env Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
app/main.py Outdated Show resolved Hide resolved
tests/test_query.py Show resolved Hide resolved
tests/test_query.py Show resolved Hide resolved
@alyssadai alyssadai requested a review from surchs August 31, 2023 01:41
Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

looks good @alyssadai, 🧑‍🍳

app/api/utility.py Outdated Show resolved Hide resolved
@alyssadai alyssadai merged commit 0e7491c into main Aug 31, 2023
4 checks passed
@alyssadai alyssadai deleted the iss-150/configurable-CORS-origins branch August 31, 2023 16:12
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.

Make allowed origins for CORS configurable
3 participants