-
-
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
Proposal: Introduce Feature Flags for Modular Build Configuration #3777
Comments
A few first thoughts on the topic:
TLDR: While I am not really interested in being able to turn off all the features you mentioned above for myself, I can see a lot of upside in going in that direction for the changes required to get there. That being said - I think figuring out how to work with cabal flags, the C preprocessor etc. would be the simple part. It will be much harder to split the code-base up nicely, so that this actually works. It would require major refactoring - something that @monacoremo started a long time ago in #1804, but hasn't been continued in a while. |
FWIW, I think both would be used together. You set a cabal flag, which you can then use in CPP to conditionally compile. |
I assume the intent here is to separate your data layer from the "access layer" or whatever you call it. So those database functions would be that layer. Note that, to have a nice HTTP api, it's much more convenient to actually use VIEWs for that layer as well and not limit yourself to RPCs. For RPCs you only have GET and POST, while for views, you have GET, POST, PATCH, DELETE - but you can still fully control all the logic in INSTEAD OF triggers. Those are kind of similar to your RPCs, but give you a cleaner interface. We call this Schema Isolation. I strongly suggest you think about that, too.
Could you elaborate on how you are securing access to this with a focus on security but without JWT support? Curious! :) |
Hm, yeah a lot to disable. @joelonsql Maybe we should start from what you actually need? Is it just to be able to call |
This package was shared before on the subject of conditional compilation: https://hackage.haskell.org/package/plugins |
At first glance this seems very outdated, no action on github for the last two years, no supported GHC version in the 9.x series. |
Yes, only need calling functions, passing arguments as a POST data in JSON. |
Using the I haven't worked on the uniphant repo for quite some time, so it might not be working, but should be enough to give an idea on the concept. |
Yes! I forgot to mention, I actually use VIEWs also, but only for read operations, as I believe write operations are better handled via functions. When I need user-filtered data, I'm using the user_id GUC set by my RBAC implementation upon successful authentication and authorization, and then using that to filter VIEWs. Here is an example: CREATE OR REPLACE VIEW api.current_user WITH (security_barrier) AS
SELECT
user_id,
username
FROM users
WHERE user_id = user_id(); I prefer this explicit filtering, which makes it obvious when reading the view definition that it's being filtered, rather than relying on RLS. |
In my RBAC implementation, functions and views are two different resource_type's: https://github.com/truthly/uniphant/blob/master/TABLES/resources.sql#L5 |
Hello fellow PostgREST hackers,
I'm interested in exploring the possibility of introducing feature flags in PostgREST to allow users to exclude specific existing and future features at build time, similar to Rust's feature flags or C's
./configure --without-[feature]
. I believe this could make PostgREST more modular and customizable, enabling users to build it with only the functionalities they require. This approach could enhance security by reducing the attack surface and improve performance through lower memory consumption.I'm curious if Haskell supports this kind of conditional compilation. I've read a bit about Cabal Flags but am unsure whether they would just disable code or actually exclude it from being built. I've also learned that Haskell can use the C Preprocessor (CPP) for conditional compilation. I'm not certain which approach would be best and would greatly appreciate any input or suggestions!
Personally, I'm particularly interested in building an RPC-only version of PostgREST. I've successfully built production systems that accessed PostgreSQL strictly via database functions, without needing the following functionalities:
I'm eager to contribute to this effort and would love to hear your thoughts on its feasibility and value to the project.
Thank you!
Joel Jacobson
The text was updated successfully, but these errors were encountered: