Repository navigation
feat(mpg): show customer roles and limit custom users to databases - #5379
Open
miguel-fly wants to merge 7 commits into
Open
miguel-fly wants to merge 7 commits into
miguel-fly wants to merge 7 commits into
Conversation
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.
Issue
Problem
fly mpg users listshows only each user's built-in role. Roles made with SQL, and which databases a user can reach, don't show anywhere in flyctlcustomuser, who gets only what an admin grants, or to limit a user to some databasesfly mpg attachcan write aDATABASE_URLfor a database the chosen user can't reachSolution
fly mpg users listshows each user's roles and databases, and newfly mpg rolescommands list roles and their membersfly mpg users createand the newfly mpg users set-databasesmakecustomusers and limit them to some databasesfly mpg attachoffers only databases the chosen user can reachDetails
fly mpg users listgains ROLES and DATABASES-for none, blank when the cluster doesn't report them yet, with a note on stderrall, the list,none, orunknownfor a user with no built-in role, whose access comes from SQL grants-for a user with no built-in role--jsonaddsroles,databases_limitedanddatabasesfly mpg users createtakes-r customand-d <database>, repeatable-dalone pickscustom, the only role that can be limited-dwith another role is refused before any call-r customasks which databasesfly mpg users set-databases--database(repeatable) or--all-databases; interactive runs ask--yesskips itfly mpg roles listandfly mpg roles members -r <role>fly mpg attach:customfor a new user, since a new custom user can't read anythingIt arrives with a scheduled update in the cluster's maintenance window.-d, set-role and delete. Create with-d, set-databases and the roles commands call flaps onlyExamples
Example 1: list users
sql_loginhas no built-in role. Its access comes from SQL grants, so DATABASES saysunknownExample 2: create a custom user limited to two databases
Example 3: limit a user to one database
--yes, it asks:Limit analyst to app1 in cluster my-cluster-id? Its sessions in other databases will be ended.Example 4: list roles
Example 5: list a role's members
Example 6:
-dwith a built-in role (error)Example 7: a cluster that isn't updated yet (error)
Example 8: attach a limited user to a database it can't reach (error)
Notes
fly mpg attach --usernamenow lists the cluster's users to check the user's limits. If that list fails, attach fails instead of writing a URL that may not connectusers list --jsonandrolescommands with--jsonneed the cluster id, so they never promptcustomas text, and refuses-r customlocallyRollout
miguel/managed-postgres-roles(likely v0.11.10). go.mod still needs that bumpmiguel/mpg-list-roles-apiandmiguel/mpg-user-databases-apiare deployedmiguel/flaps-mpg-rolesandmiguel/flaps-mpg-user-databaseshas finished. Hosts not yet updated answer 404 for the new routes, and flyctl doesn't fall back for them