Skip to content

Commit

Permalink
support specific accounts to access all databases
Browse files Browse the repository at this point in the history
Signed-off-by: fupeng29 <[email protected]>
  • Loading branch information
fupeng29 committed Nov 7, 2023
1 parent 1fbbfbf commit 6e4c9ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"MysqlNativePassword": "*E361D58BFE0A57E237D51CE49E8E395E65538AA9",
"UserData": "",
"KeySpaces": [
{"Name":"customer", "WhiteIPs": []}
{"Name":"*", "WhiteIPs": []}
],
"Privilege": 1,
"ReadRole": 1
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/auth_server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (asc *AuthServerConfig) ValidClient(user, keyspace, ip string) bool {
return entry.KeySpaces[0].IPFilter.FilterIPString(ip)
}
for _, ks := range entry.KeySpaces {
if ks.Name == keyspace {
if ks.Name == keyspace || ks.Name == "*" {
if len(ks.WhiteIPs) == 0 {
return true
}
Expand Down
6 changes: 5 additions & 1 deletion go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,11 @@ func (e *Executor) handleShow(ctx context.Context, sql string) (*sqltypes.Result

var destKeyspaces []string
if len(userKeyspace) > 0 {
destKeyspaces = intersect(userKeyspace, allKeyspace)
if len(userKeyspace) == 1 && userKeyspace[0] == "*" {
destKeyspaces = allKeyspace
} else {
destKeyspaces = intersect(userKeyspace, allKeyspace)
}
} else {
destKeyspaces = allKeyspace
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/plugin_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ func (vh *vtgateHandler) ValidUseDB(c *mysql.Conn, usedb string, authServer mysq
usedb = strings.Split(usedb, ":")[0]

for _, usks := range userkss {
if strings.EqualFold(usks, usedb) {
if strings.EqualFold(usks, usedb) || usks == "*" {
return nil
}
}
Expand Down

0 comments on commit 6e4c9ef

Please sign in to comment.