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

Remove key check bypass and add ability to pass key in Authorization header #21

Merged
merged 2 commits into from
Jul 7, 2024

Conversation

rosswhitfield
Copy link
Member

@rosswhitfield rosswhitfield commented Jul 5, 2024

This will first check the secret key in the HTTP Authorization request header before falling back to checking for the query string for the key. Once WebMon and WebRef support the new method the check for key in the query string should be removed.

Once you run the tests you can test manually test this with curl, e.g. the following two command should return the same

curl -k 127.0.0.1/plots/instrument0/123/update/json/?key=8c43bacc1c565d1febf2bbbb99319b0a7513f4a7
curl -k 127.0.0.1/plots/instrument0/123/update/json/ --header "Authorization: 8c43bacc1c565d1febf2bbbb99319b0a7513f4a7"

Half the tests were updated to use the new Authorization header approach and the other half use the old method.

Ref: 5923: [LiveDataServer] Change API key handling

Short description of the changes:

Long description of the changes:

Check list for the pull request

  • I have read the [CONTRIBUTING]
  • I have read the [CODE_OF_CONDUCT]
  • I have added tests for my changes
  • I have updated the documentation accordingly

Check list for the reviewer

  • I have read the [CONTRIBUTING]
  • I have verified the proposed changes
  • best software practices
    • all internal functions have an underbar, as is python standard
    • clearly named variables (better to be verbose in variable names)
    • code comments explaining the intent of code blocks
  • All the tests are passing
  • The documentation is up to date
  • code comments added when explaining intent

Manual test for the reviewer

References

This will fall back to checking for the query string for key which should be remove after WebMon/WebRef support the new method.
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.87%. Comparing base (0f54021) to head (e754bee).

Files Patch % Lines
src/live_data_server/plots/view_util.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next      #21      +/-   ##
==========================================
- Coverage   87.14%   86.87%   -0.27%     
==========================================
  Files          10       10              
  Lines         280      282       +2     
==========================================
+ Hits          244      245       +1     
- Misses         36       37       +1     

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

@rosswhitfield rosswhitfield changed the title Remove key check bypass and add abilty to pass key in Authorization header Remove key check bypass and add ability to pass key in Authorization header Jul 5, 2024
Copy link
Collaborator

@backmari backmari left a comment

Choose a reason for hiding this comment

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

This PR removes the temporary bypass that allowed clients to fetch data from Live Data Server without providing an API key. The manual test and the unit tests passed locally. Looks good to me 👌

As mentioned in the PR description, the option to authorize with the key in the URL will be removed once all clients have been updated to use the authorization header.

@rosswhitfield rosswhitfield merged commit 7b2b256 into next Jul 7, 2024
2 of 4 checks passed
@rosswhitfield rosswhitfield deleted the update_check_key branch July 7, 2024 23:26
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