-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Generate database access credentials with tctl auth sign command #10785
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few minor comments.
tool/tctl/common/auth_command.go
Outdated
case a.dbName != "": | ||
server, err := getDatabaseServer(context.TODO(), clusterAPI, a.dbName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now we are using --db-name
to provide the name od database instance where in tsh login/connect
the --db-name
refers to a database name scheme. For example:
tsh db connect --db-user=postgres --db-name=testdb postgres-instance
This might be unintuitive also in current approach also the Database
field is not set in:
routeToDatabase = proto.RouteToDatabase{
ServiceName: a.dbName,
Protocol: server.GetDatabase().GetProtocol(),
Username: a.dbUser,
}
so there is no way to specify the --db-name to connect in case of postgres access where databaseName is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting point, but it is hard to name the ServiceName
property into something else since in some places (like the UI and the command you mentioned), it is called "database name".
What about setting the flags like this:
--db
: Refers to theServiceName
property fromRouteToDatabase
;--db-name
: Refers to theDatabase
property fromRouteToDatabase
;--db-user
: Refers to theUsername
property fromRouteToDatabase
;
Another question related to this: is the parameter (Database
) required only in some database types? if so should we add validation to it (for example, if PostgreSQL requires it, we make the flag required)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, the --db-name
is a bit misleading because and it should be somehow distinguishable from RouteToDatabase.ServiceName
a new flog --db
or --db-service
should fix this and to allow to provide full RouteToDatabase
information
@r0mant Any objection ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for delay here guys, yeah I think --db-service
, --db-user
and --db-name
makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Updated the flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm after the remaining comment is addressed.
) * feat(tctl): sign command to generate database access credentials * feat(tctl): make auth sign parameters app-name and db-name mutually exclusive * feat(tctl): add flag db-user to auth sign command * test(tctl): remove references to deprecated package ioutil * test(tctl): update test to check error type * chore(tctl): add godoc to `getDatabaseServer` function * refactor(tctl): rename database-related flags in auth sign * refactor(tctl): rename flag from `db` to `db-service`
) * feat(tctl): sign command to generate database access credentials * feat(tctl): make auth sign parameters app-name and db-name mutually exclusive * feat(tctl): add flag db-user to auth sign command * test(tctl): remove references to deprecated package ioutil * test(tctl): update test to check error type * chore(tctl): add godoc to `getDatabaseServer` function * refactor(tctl): rename database-related flags in auth sign * refactor(tctl): rename flag from `db` to `db-service`
) (#12044) * feat(tctl): sign command to generate database access credentials * feat(tctl): make auth sign parameters app-name and db-name mutually exclusive * feat(tctl): add flag db-user to auth sign command * test(tctl): remove references to deprecated package ioutil * test(tctl): update test to check error type * chore(tctl): add godoc to `getDatabaseServer` function * refactor(tctl): rename database-related flags in auth sign * refactor(tctl): rename flag from `db` to `db-service`
) (#12042) * feat(tctl): sign command to generate database access credentials * feat(tctl): make auth sign parameters app-name and db-name mutually exclusive * feat(tctl): add flag db-user to auth sign command * test(tctl): remove references to deprecated package ioutil * test(tctl): update test to check error type * chore(tctl): add godoc to `getDatabaseServer` function * refactor(tctl): rename database-related flags in auth sign * refactor(tctl): rename flag from `db` to `db-service`
Closes #9789.
Adds the flag
--db-name
into thetctl auth sign
. When the flag is provided, the command will generate user credentials that can be used to connect to the database. In addition, it also adds the--db-user
flag so users can provide the database username to be added in the routing information.Example of usage: