[DO NOT MERGE] Demonstrate how to allow anonymous access to data. #76
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.
This is a proposal for how Platformics can support making some data public.
It shouldn't be merged into this repo, but I'm asking for feedback about whether this is an acceptable solution for #73
Currently our codegen adds a dependency to every resolver called
require_auth_principal
, which essentially checks for a valid auth token and raises an exception if there isn't one available:https://github.com/chanzuckerberg/platformics/blob/main/platformics/api/core/deps.py#L107-L112
This is OK for API's that only need to be accessible to authenticated users, but it falls over when an API also needs to be accessible to the public.
However, FastAPI provides a way to override dependencies, and
main.py
is controlled by application authors (that is, it isn't code-gen'd!) so we can manipulate the dependencies of our FastAPI application and override platformics default behaviors.In this example, we're overriding
require_auth_principal
to return a "dummy" anonymous principal that only has read access to certain collections that we deem to be publicly accessible.Is this a reasonable workaround to allow public access?