-
Notifications
You must be signed in to change notification settings - Fork 4
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
allow users to specify non-globalforestwatch domains in api key #532
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #532 +/- ##
===========================================
+ Coverage 81.71% 81.85% +0.13%
===========================================
Files 125 125
Lines 5618 5609 -9
===========================================
Hits 4591 4591
+ Misses 1027 1018 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -74,16 +74,8 @@ async def create_api_key( | |||
|
|||
input_data = api_key_data.dict(by_alias=True) | |||
|
|||
origin = request.headers.get("origin") | |||
referrer = request.headers.get("referer") | |||
if not api_key_is_valid(input_data["domains"], origin=origin, referrer=referrer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents users from creating api keys from anywhere but the domain they plan to use the api key for (for example, one wouldn't be able to use postman to create an api key for mapbuilder (listed in the domains request body)) because the origin or referer wouldn't point to that and this check will fail.
This check gets applied correctly checking requests coming in with an api key (https://github.com/wri/gfw-data-api/blob/master/app/authentication/api_keys.py#L53)
Pull request checklist
Please check if your PR fulfills the following requirements:
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Creating api key from non-globalforestwatch origins fails now if the user passes domains list that doesn't include globalforestwatch.
What is the new behavior?
Does this introduce a breaking change?
Other information