feat: Hide OS API key by allowing proxy endpoint#241
Merged
DafyddLlyr merged 15 commits intomainfrom Dec 21, 2022
Merged
Conversation
✅ Deploy Preview for oslmap ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
028ed19 to
3485296
Compare
3485296 to
927d886
Compare
29af790 to
d7d2bcd
Compare
- Also some improvements to error handling and boolean logic
9f55cc3 to
2fb0acc
Compare
efa6292 to
8fb65c5
Compare
Member
jessicamcinchak
left a comment
There was a problem hiding this comment.
Looking really solid 🎉 I want to come back with fresher eyes at least once more, but here's initial comments/questions. Appreciate the docs, examples and tests here - makes it much easier to review!
jessicamcinchak
approved these changes
Dec 21, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
osProxyEndpointpropertyHow is this achieved?
Before making any requests to the OS, we get the URL from
ordnanceSurvey.getServiceURL().If the user supplied an OS API key, we'll query the OS API directly and append their key. This is the exact same functionality as currently exists.
If the user supplies an
osProxyEndpointvalue, we'll construct the correct service URL, without an API key. It is the end user's responsibility to host and maintain a suitable service to proxy requests (with the correct authentication) to the OS API. Ensuring proper access to the proxy endpoint can be done through CORS/CORP on the proxy. The documentation in this repository outlines how this can be achieved.Testing
In order to test this, you can run the dev server locally and add the
osProxyEndpoint="https://api.planx.dev/proxy/ordnance-survey"property to themy-maporaddress-autocompletecomponents. This will also work on the "Deploy Preview" link generated by the PR.A number of unit test and service / integration tests have also been added to cover the new functionality, but there's plenty more that could be added to cover all scenarios. I think I've captured the main journeys here but please let me know if you think we need more coverage anywhere.
Documentation
Pitsby doesn't allow markup or any rich text (even line breaks) in it's descriptions, so linking back to a richer markdown page seemed helpful here.