-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support all Trino Security Access Control modes in Delta lake Connector
- Loading branch information
Showing
10 changed files
with
237 additions
and
121 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
30 changes: 0 additions & 30 deletions
30
...a-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeAccessControlMetadataFactory.java
This file was deleted.
Oops, something went wrong.
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
47 changes: 47 additions & 0 deletions
47
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSecurityConfig.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,47 @@ | ||
/* | ||
* Licensed 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 io.trino.plugin.deltalake; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import static io.trino.plugin.deltalake.DeltaLakeSecurityConfig.DeltaLakeSecurity.ALLOW_ALL; | ||
|
||
public class DeltaLakeSecurityConfig | ||
{ | ||
public enum DeltaLakeSecurity | ||
{ | ||
ALLOW_ALL, | ||
READ_ONLY, | ||
SYSTEM, | ||
FILE, | ||
} | ||
|
||
private DeltaLakeSecurity securitySystem = ALLOW_ALL; | ||
|
||
@NotNull | ||
public DeltaLakeSecurity getSecuritySystem() | ||
{ | ||
return securitySystem; | ||
} | ||
|
||
@Config("delta.security") | ||
@ConfigDescription("Authorization checks for Delta Lake connector") | ||
public DeltaLakeSecurityConfig setSecuritySystem(DeltaLakeSecurity securitySystem) | ||
{ | ||
this.securitySystem = securitySystem; | ||
return this; | ||
}} |
50 changes: 50 additions & 0 deletions
50
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSecurityModule.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 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 io.trino.plugin.deltalake; | ||
|
||
import com.google.inject.Binder; | ||
import com.google.inject.Module; | ||
import io.airlift.configuration.AbstractConfigurationAwareModule; | ||
import io.trino.plugin.base.security.ConnectorAccessControlModule; | ||
import io.trino.plugin.base.security.FileBasedAccessControlModule; | ||
import io.trino.plugin.base.security.ReadOnlySecurityModule; | ||
import io.trino.plugin.deltalake.DeltaLakeSecurityConfig.DeltaLakeSecurity; | ||
import io.trino.plugin.hive.security.AllowAllSecurityModule; | ||
|
||
import static io.airlift.configuration.ConditionalModule.conditionalModule; | ||
import static io.trino.plugin.deltalake.DeltaLakeSecurityConfig.DeltaLakeSecurity.ALLOW_ALL; | ||
import static io.trino.plugin.deltalake.DeltaLakeSecurityConfig.DeltaLakeSecurity.FILE; | ||
import static io.trino.plugin.deltalake.DeltaLakeSecurityConfig.DeltaLakeSecurity.READ_ONLY; | ||
|
||
public class DeltaLakeSecurityModule | ||
extends AbstractConfigurationAwareModule | ||
{ | ||
@Override | ||
protected void setup(Binder binder) | ||
{ | ||
install(new ConnectorAccessControlModule()); | ||
bindSecurityModule(ALLOW_ALL, new AllowAllSecurityModule()); | ||
bindSecurityModule(READ_ONLY, new ReadOnlySecurityModule()); | ||
bindSecurityModule(FILE, new FileBasedAccessControlModule()); | ||
// SYSTEM: do not bind an ConnectorAccessControl so the engine will use system security with system roles | ||
} | ||
|
||
private void bindSecurityModule(DeltaLakeSecurity deltaLakeSecurity, Module module) | ||
{ | ||
install(conditionalModule( | ||
DeltaLakeSecurityConfig.class, | ||
security -> deltaLakeSecurity == security.getSecuritySystem(), | ||
module)); | ||
} | ||
} |
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.