Skip to content

Commit

Permalink
Make sure that file based access control have coherent config properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kokosing committed Oct 28, 2018
1 parent cd0f7ff commit 52cff69
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions presto-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
<artifactId>jaxrs-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-plugin-toolkit</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Set;
import java.util.regex.Pattern;

import static com.facebook.presto.plugin.base.security.FileBasedAccessControlConfig.SECURITY_CONFIG_FILE;
import static com.facebook.presto.spi.security.AccessDeniedException.denyCatalogAccess;
import static com.facebook.presto.spi.security.AccessDeniedException.denySetUser;
import static com.google.common.base.Preconditions.checkState;
Expand All @@ -61,8 +62,6 @@ private FileBasedSystemAccessControl(List<CatalogAccessControlRule> catalogRules
public static class Factory
implements SystemAccessControlFactory
{
static final String CONFIG_FILE_NAME = "security.config-file";

@Override
public String getName()
{
Expand All @@ -74,10 +73,8 @@ public SystemAccessControl create(Map<String, String> config)
{
requireNonNull(config, "config is null");

String configFileName = config.get(CONFIG_FILE_NAME);
checkState(
configFileName != null,
"Security configuration must contain the '%s' property", CONFIG_FILE_NAME);
String configFileName = config.get(SECURITY_CONFIG_FILE);
checkState(configFileName != null, "Security configuration must contain the '%s' property", SECURITY_CONFIG_FILE);

try {
Path path = Paths.get(configFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.Optional;
import java.util.Set;

import static com.facebook.presto.security.FileBasedSystemAccessControl.Factory.CONFIG_FILE_NAME;
import static com.facebook.presto.plugin.base.security.FileBasedAccessControlConfig.SECURITY_CONFIG_FILE;
import static com.facebook.presto.spi.security.Privilege.SELECT;
import static com.facebook.presto.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden;
import static com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager;
Expand Down Expand Up @@ -213,6 +213,6 @@ public void parseUnknownRules()

private SystemAccessControl parse(String path)
{
return new FileBasedSystemAccessControl.Factory().create(ImmutableMap.of(CONFIG_FILE_NAME, path));
return new FileBasedSystemAccessControl.Factory().create(ImmutableMap.of(SECURITY_CONFIG_FILE, path));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

public class FileBasedAccessControlConfig
{
public static final String SECURITY_CONFIG_FILE = "security.config-file";

private String configFile;

@NotNull
Expand All @@ -27,7 +29,7 @@ public String getConfigFile()
return configFile;
}

@Config("security.config-file")
@Config(SECURITY_CONFIG_FILE)
public FileBasedAccessControlConfig setConfigFile(String configFile)
{
this.configFile = configFile;
Expand Down

0 comments on commit 52cff69

Please sign in to comment.