-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix privilege check in CreateDatabaseBackendHandler (#32)
- Loading branch information
1 parent
1e156c9
commit 8324e65
Showing
17 changed files
with
311 additions
and
13 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...ority/core/src/main/java/com/sphereex/dbplusengine/authority/obj/domain/RALACLObject.java
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,26 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.sphereex.dbplusengine.authority.obj.domain; | ||
|
||
import com.sphereex.dbplusengine.authority.model.obj.ACLObject; | ||
|
||
/** | ||
* RAL ACL object. | ||
*/ | ||
public final class RALACLObject implements ACLObject { | ||
} |
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
45 changes: 45 additions & 0 deletions
45
.../dbplusengine/authority/obj/extractor/type/ddl/type/CreateDatabaseACLObjectExtractor.java
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,45 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.sphereex.dbplusengine.authority.obj.extractor.type.ddl.type; | ||
|
||
import com.sphereex.dbplusengine.authority.model.obj.ACLObject; | ||
import com.sphereex.dbplusengine.authority.obj.domain.TableACLObject; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.shardingsphere.authority.constant.AuthorityConstants; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CreateDatabaseStatement; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Create database ACL object extractor. | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class CreateDatabaseACLObjectExtractor { | ||
|
||
/** | ||
* Extract ACL objects. | ||
* | ||
* @param sqlStatement create database statement | ||
* @return extracted ACL objects | ||
*/ | ||
public static Collection<ACLObject> extract(final CreateDatabaseStatement sqlStatement) { | ||
return Collections.singleton(new TableACLObject(sqlStatement.getDatabaseName(), AuthorityConstants.PRIVILEGE_WILDCARD)); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...eex/dbplusengine/authority/obj/extractor/type/ddl/type/CreateIndexACLObjectExtractor.java
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,50 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.sphereex.dbplusengine.authority.obj.extractor.type.ddl.type; | ||
|
||
import com.sphereex.dbplusengine.authority.model.obj.ACLObject; | ||
import com.sphereex.dbplusengine.authority.obj.domain.TableACLObject; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CreateIndexStatement; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Create index ACL object extractor. | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class CreateIndexACLObjectExtractor { | ||
|
||
/** | ||
* Extract ACL objects. | ||
* | ||
* @param currentDatabase current database name | ||
* @param sqlStatement create index statement | ||
* @return extracted ACL objects | ||
*/ | ||
public static Collection<ACLObject> extract(final String currentDatabase, final CreateIndexStatement sqlStatement) { | ||
if (null == sqlStatement.getTable()) { | ||
return Collections.emptyList(); | ||
} | ||
String database = sqlStatement.getTable().getOwner().map(optional -> optional.getIdentifier().getValue()).orElse(currentDatabase); | ||
String table = sqlStatement.getTable().getTableName().getIdentifier().getValue(); | ||
return Collections.singleton(new TableACLObject(database, table)); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ereex/dbplusengine/authority/obj/extractor/type/ddl/type/DropIndexACLObjectExtractor.java
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,46 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.sphereex.dbplusengine.authority.obj.extractor.type.ddl.type; | ||
|
||
import com.sphereex.dbplusengine.authority.model.obj.ACLObject; | ||
import com.sphereex.dbplusengine.authority.obj.extractor.type.dal.dialect.MySQLACLObjectExtractor; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropIndexStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.mysql.MySQLStatement; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Drop index ACL object extractor. | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class DropIndexACLObjectExtractor { | ||
|
||
/** | ||
* Extract ACL objects. | ||
* | ||
* @param currentDatabase current database name | ||
* @param sqlStatement drop index statement | ||
* @return extracted ACL objects | ||
*/ | ||
public static Collection<ACLObject> extract(final String currentDatabase, final DropIndexStatement sqlStatement) { | ||
return sqlStatement instanceof MySQLStatement ? MySQLACLObjectExtractor.extract(currentDatabase, (MySQLStatement) sqlStatement) : Collections.emptyList(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,4 +21,5 @@ rules: | |
users: | ||
- user: root@% | ||
password: 123456 | ||
admin: true | ||
#SPEX ADDED: END |
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
Oops, something went wrong.