-
Notifications
You must be signed in to change notification settings - Fork 3
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 user permissions issues for Postgresql #50
Comments
Here's some history: I think your option 4 name is really just "to use one username per database". I don't think we can do anything better if the CF broker API is still like it was when I last researched the problem. Option 4 is probably the most practical one overall for now. Our ideal solution doesn't seem to be possible without a lot more work patching CF (or, heck, Postgres). |
Thanks Simon, that's a better description (I'll see if I can edit the original to use it). It feels like client certificate authentication would work reasonably here too (multiple certs for the same username) but given that CF doesn't seem to have a good way of rotating creds, and that RDS (as far as I can tell) doesn't actually support client certs, that's a non-starter too. |
I also like option4. Regarding |
Hey guys, there are a few threads here, and sorry if I miss some explicit/implicit questions. Couple of ideas:
|
Thanks @drnic. Someone has also pointed me to the AlphaGov fork which seems much better supported. They've also addressed this particular issue with this PR, which appears to be similar to our option 4. I think we might go with our own option 4 for our immediate needs, and then look at whether it make more sense to switch to the AlphaGov fork. |
@drnic I am not doing gov work anymore so I think it's best for someone else to take over if help is needed. As you say there are lots of admins and they can merge the PRs. |
When an application is bound to a service, the broker currently creates a username/password specific to that binding so that each application bound to a service has separate credentials.
It is expected that each of these users has the same access to the same underlying resource.
This is achieved easily enough with MySQL, however when database objects (such as tables) are created in Postgresql, by default that object is owned by the user that created it and other users need to be explicitly granted permission to access it (simply having permissions on the database that contains the object isn't enough to give direct permission to query over the objects).
For blue/green deployments, it is common practice to need to have 2 different applications to be able to access the same database.
Currently when using tools such as
cf bgd
(link) to push apps, a second application is automatically created, and services are automatically bound to it based on theservices
listed in themanifest.yml
.Since the second application has a different username to the first, as soon as code in the application tries to access tables in the database, it fails with permission denied errors.
Option 1 (currently implemented): Provide hook at service bind time to choose database username
To workaround this issue, the service broker currently allows specification (at service bind time) of a specific username to use when connecting to the database. See here for details.
This has the following issues:
manifest.yml
, which does not support extra parameters), which some blue/green tools useOption 2: Modify the Postgres binding code to ensure the new user has sufficient permissions
We could explore creating making additional calls at bind time to enumerate the schemas in the database, then use
GRANT ALL PRIVILEGES TO ALL TABLES IN SCHEMA ...
etc to give the new user appropriate permissions.This has the following issues:
ALL xxx
optionOption 3: Modify the applications to use an additional role that they grant access to
We could advise delivery teams to modify their applications to ensure that created objects are always followed by an additional
GRANT ...
that gives appropriate permissions to a common role for that database.This has the following issues:
Option 4: Modify the service broker to always use the same username for the same database with Postgresql
Modify the service broker such that for Postgresql it will only ever create a single user (calculated on the same name as the database that it creates) and share this across each application that binds to that service.
This is basically the same as option 1 - but always done (removing complexity for clients), and without allowing a user specified name (mitigating confused deputy risks).
This has the following issues:
Option 5: ?
The text was updated successfully, but these errors were encountered: