forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[improvement](auth) support show view priv (apache#25370)
Issue Number: close #xxx current ,if user has select_priv or load_priv,he can show create table view_name, but this is not safe,so add show_view_priv for show create table view_name mysql SHOW VIEW description: https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_show-view
- Loading branch information
Showing
8 changed files
with
197 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
suite("test_auth_show", "account") { | ||
|
||
def create_table = { tableName -> | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
sql """ | ||
CREATE TABLE ${tableName} ( | ||
`key` INT, | ||
value INT | ||
) DUPLICATE KEY (`key`) DISTRIBUTED BY HASH (`key`) BUCKETS 1 | ||
PROPERTIES ('replication_num' = '1') | ||
""" | ||
} | ||
|
||
def user = 'acount_auth_show_user' | ||
def pwd = 'C123_567p' | ||
def dbName = 'account_auth_show_db' | ||
def tableName = 'account_auth_show_table' | ||
|
||
try_sql("DROP USER ${user}") | ||
sql """DROP DATABASE IF EXISTS ${dbName}""" | ||
sql """CREATE DATABASE ${dbName}""" | ||
sql """USE ${dbName}""" | ||
create_table.call(tableName); | ||
sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'""" | ||
|
||
def tokens = context.config.jdbcUrl.split('/') | ||
def url=tokens[0] + "//" + tokens[2] + "/" + dbName + "?" | ||
|
||
// With select priv for table, should be able to see db | ||
sql """GRANT SELECT_PRIV ON ${dbName}.${tableName} TO ${user}""" | ||
def result1 = connect(user=user, password="${pwd}", url=url) { | ||
sql """show databases like '${dbName}'""" | ||
} | ||
assertEquals(result1.size(), 1) | ||
sql """REVOKE SELECT_PRIV ON ${dbName}.${tableName} FROM ${user}""" | ||
|
||
// With show_view priv for table, should be able to see db | ||
sql """GRANT SHOW_VIEW_PRIV ON ${dbName}.${tableName} TO ${user}""" | ||
def result2 = connect(user=user, password="${pwd}", url=url) { | ||
sql """show databases like '${dbName}'""" | ||
} | ||
assertEquals(result2.size(), 1) | ||
sql """REVOKE SHOW_VIEW_PRIV ON ${dbName}.${tableName} FROM ${user}""" | ||
} | ||
|