-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix OpenApi output for mode follow-privileges #2357
Fix OpenApi output for mode follow-privileges #2357
Conversation
@wolfgangwalther As a workaround, if you use |
On postgrest/src/PostgREST/App.hs Lines 487 to 500 in ee906da
The schema cache is augmented with postgrest/src/PostgREST/DbStructure.hs Lines 85 to 95 in ee906da
|
Before #2254
The above was not done and the PKCols were a separate element in the schema cache and this was used for the OpenAPI output. The fix would be to add Edit: The above can't be done because Ideally I think we'd use the schema cache for Edit: This could also let us reject unauthorized requests at the postgREST level. There's some value in not touching the db when we know the user isn't able to fulfill the request(similar to #1094). |
Another alternative that seems simpler. On There would be no caching if we go this way, but that could be added later. |
I tried that and it seems like it works... but not quite, yet. It looks like PKs are not detected through multiple views recursively anymore. So one view selects from another view which selects a PK from a table. Does this make sense? Is this expected, because of changes to embedding? Or should I try to put together a test-case? |
Hm. The few ones I'm still missing might also be related to multi column PKs. Will have to put a test-case together, eventually, I guess. |
Hm, no. PK detection on views recursively should work. I didn't expect to break that. A test case would be great, yes. |
What about running a query to only fetch the current privileges each time the openapi output is requested - and then applying those privileges to the schema cache? |
ee906da
to
6b5f916
Compare
I did it this way for the tables query. Doing the same for accessibleProcs would be a bit more effort, because those are not uniquely identified by schema/name alone. @steve-chavez WDYT? This is based on #2526, so that commit shows up here, too. |
This was introduced in d5b92a4. Before this change, the OpenApi output would have <pk/> annotations for views, too. After this change, they got lost for mode follow-privileges, because the pks are refined in haskell code, but the request only fetches all the tables again, but not the view dependencies. This fix changes follow-privileges to only fetch a list of accessible tables, which is then used to filter the tables in the schema cache. Fixes PostgREST#2356 Signed-off-by: Wolfgang Walther <walther@technowledgy.de>
c576af8
to
3bee6b1
Compare
This demonstrates a breaking change in the latest pre-release by adding a new test for openapi output of views.
Related to #2356.