Skip to content

Commit

Permalink
Inject AccessControl to SessionPropertyDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkadiusz Czajkowski authored and losipiuk committed Nov 10, 2021
1 parent e173be4 commit 66948b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.airlift.log.Logger;
import io.airlift.node.NodeInfo;
import io.trino.Session;
import io.trino.security.AccessControl;
import io.trino.spi.classloader.ThreadContextClassLoader;
import io.trino.spi.resourcegroups.ResourceGroupId;
import io.trino.spi.resourcegroups.SessionPropertyConfigurationManagerContext;
Expand All @@ -38,6 +39,7 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static io.airlift.configuration.ConfigurationLoader.loadPropertiesFrom;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

public class SessionPropertyDefaults
{
Expand All @@ -50,10 +52,13 @@ public class SessionPropertyDefaults
private final Map<String, SessionPropertyConfigurationManagerFactory> factories = new ConcurrentHashMap<>();
private final AtomicReference<SessionPropertyConfigurationManager> delegate = new AtomicReference<>();

private final AccessControl accessControl;

@Inject
public SessionPropertyDefaults(NodeInfo nodeInfo)
public SessionPropertyDefaults(NodeInfo nodeInfo, AccessControl accessControl)
{
this.configurationManagerContext = new SessionPropertyConfigurationManagerContextInstance(nodeInfo.getEnvironment());
this.accessControl = requireNonNull(accessControl, "accessControl is null");
}

public void addConfigurationManagerFactory(SessionPropertyConfigurationManagerFactory sessionConfigFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private LocalQueryRunner(
Optional.of(new HeaderAuthenticatorManager(new HeaderAuthenticatorConfig())),
eventListenerManager,
new GroupProviderManager(),
new SessionPropertyDefaults(nodeInfo));
new SessionPropertyDefaults(nodeInfo, accessControl));

connectorManager.addConnectorFactory(globalSystemConnectorFactory, globalSystemConnectorFactory.getClass()::getClassLoader);
connectorManager.createCatalog(GlobalSystemConnector.NAME, GlobalSystemConnector.NAME, ImmutableMap.of());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.trino.spi.security.Identity;
import io.trino.spi.session.SessionPropertyConfigurationManagerFactory;
import io.trino.spi.session.TestingSessionPropertyConfigurationManagerFactory;
import io.trino.testing.AllowAllAccessControlManager;
import org.testng.annotations.Test;

import java.util.Optional;
Expand All @@ -39,7 +40,7 @@ public class TestSessionPropertyDefaults
@Test
public void testApplyDefaultProperties()
{
SessionPropertyDefaults sessionPropertyDefaults = new SessionPropertyDefaults(TEST_NODE_INFO);
SessionPropertyDefaults sessionPropertyDefaults = new SessionPropertyDefaults(TEST_NODE_INFO, new AllowAllAccessControlManager());
SessionPropertyConfigurationManagerFactory factory = new TestingSessionPropertyConfigurationManagerFactory(
ImmutableMap.<String, String>builder()
.put(QUERY_MAX_MEMORY, "override")
Expand Down

0 comments on commit 66948b3

Please sign in to comment.