Explicit public API routes#273
Merged
Merged
Conversation
Accepts the same parameters as the LiveViews, but returns a JSON response.
Moving the agent secret check into a router pipeline meant Plug.Parsers ran before it, so unauthenticated requests had their body parsed before being rejected. Restore BobWeb.Plugs.Secret in the endpoint and instead exempt the two public, read-only search routes from it, keeping the pre-parse rejection for all authenticated /api routes and restoring the test that asserts it.
The module kept its name from the content-negotiation PR; it now covers both public endpoints and lives in public_api_test.exs.
5fa3ac1 to
741598c
Compare
Member
|
Thank you! 💜 |
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.
Alternative to #272.
@ericmj feel free to take over here. I added a new public API controller. Then I moved the API authentication into the router, because I shared the /api namespace with both private and public routes. This means that I had to comment one test that asserted that auth is checked before request parsing. The alternative would be to either use a different route, e.g.
/api/public/...//public-api/...etc., or explicitly whitelist in the secret plug to keep the same behavior.