SHOW DATABASES is Unauthorized for non-admin users
expected behavior is for influx to show databases for which the user has grants.
You might be right. Can you provide some examples from industry that show this policy in effect?
i have an application that collects data and sends to a remote influxdb. it needs to use an account that has read/write only for a particular set of databases, but also should be able to present that list of databases to the user.
This way if I create a new database and grant read/write to the account, then the user will see that database listed as an option, without me having to type it out in an email and have the user type it in to their interface.
OK, I see where you are going.
@beckettsean -- what do you think about this?
@otoolep I agree that users should be able to see the databases to which they have read or write access. I can also confirm that as of my last testing, only cluster admins can execute SHOW DATABASES.
@rkuchan anything to add?
This shouldn't be too hard to add. I can take a stab at it.
@sean, nothing to add on the SHOW DATABASES front. Only admin users can execute SHOW GRANTS which may also be useful for non-admin users.
I think we have to leave SHOW GRANTS behind admin rights or else make SHOW USERS one that doesn't require admin rights. Otherwise SHOW GRANTS is a trivial back-door to the SHOW USERS functionality. If it returns a value, the user exists. If it returns an error, the user doesn't exist.
Not to add a empty +1, but I would really appreciate this so I didn't have to email full admin credentials to less technically inclined collaborators just to use the web interface
Whats the status on this ?
/T
Is there any plan to solve this issue?
There's a bit of a discrepancy in permissions when looking at SHOW DATABASES, compared to SHOW CONTINUOUS QUERIES:
Compare these in influxql/ast.go:
func (s *ShowContinuousQueriesStatement) RequiredPrivileges() (ExecutionPrivileges, error) {
return ExecutionPrivileges{{Admin: false, Name: "", Privilege: ReadPrivilege}}, nil
}
vs.
func (s *ShowDatabasesStatement) RequiredPrivileges() (ExecutionPrivileges, error) {
return ExecutionPrivileges{{Admin: true, Name: "", Privilege: AllPrivileges}}, nil
}
And now let's see what they do in coordinator/statement_executor.go:
func (e *StatementExecutor) executeShowContinuousQueriesStatement(stmt *influxql.ShowContinuousQueriesStatement) (models.Rows, error) {
dis := e.MetaClient.Databases()
rows := []*models.Row{}
for _, di := range dis {
row := &models.Row{Columns: []string{"name", "query"}, Name: di.Name}
for _, cqi := range di.ContinuousQueries {
row.Values = append(row.Values, []interface{}{cqi.Name, cqi.Query})
}
rows = append(rows, row)
}
return rows, nil
}
vs.
func (e *StatementExecutor) executeShowDatabasesStatement(q *influxql.ShowDatabasesStatement) (models.Rows, error) {
dis := e.MetaClient.Databases()
row := &models.Row{Name: "databases", Columns: []string{"name"}}
for _, di := range dis {
row.Values = append(row.Values, []interface{}{di.Name})
}
return []*models.Row{row}, nil
}
They both iterate over e.MetaClient.Databases() and pass the resulting database name in their results, yet one has Admin: true, the other doesn't, and one needs AllPrivilege, the other only ReadPrivilege.
If I'd had to say which of the ExecutionPrivileges is right, I'd say the one from ShowContinuousQueriesStatement, but I can see why people would like to require at least some privileges for each database listed in the returned data.