Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import com.facebook.presto.spi.connector.ConnectorTransactionHandle;
import com.facebook.presto.spi.security.ConnectorIdentity;
import com.facebook.presto.spi.security.Identity;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import java.util.Optional;

import static com.facebook.presto.metadata.SessionPropertyManager.createTestingSessionPropertyManager;

Expand All @@ -35,7 +39,7 @@ public static Session toSession(ConnectorTransactionHandle transactionHandle, Co
{
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
ConnectorIdentity connectorIdentity = session.getIdentity();
Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal(), connectorIdentity.getExtraCredentials());
Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal(), ImmutableMap.of(), connectorIdentity.getExtraCredentials(), ImmutableMap.of(), Optional.empty(), connectorIdentity.getReasonForSelect(), ImmutableList.of());
return Session.builder(createTestingSessionPropertyManager(SYSTEM_SESSION_PROPERTIES))
.setQueryId(new QueryId(session.getQueryId()))
.setTransactionId(transactionId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static Session buildOwnerSession(Session session, Optional<String> owner,
public static Identity getOwnerIdentity(Optional<String> owner, Session session)
{
if (owner.isPresent() && !owner.get().equals(session.getIdentity().getUser())) {
return new Identity(owner.get(), Optional.empty(), session.getIdentity().getExtraCredentials());
return new Identity(owner.get(), Optional.empty(), ImmutableMap.of(), session.getIdentity().getExtraCredentials(), ImmutableMap.of(), Optional.empty(), session.getIdentity().getReasonForSelect(), ImmutableList.of());
}
return session.getIdentity();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,7 @@ private VersionType toVersionType(TableVersionType type)
}
throw new SemanticException(NOT_SUPPORTED, "Table version type %s not supported." + type);
}

private Optional<TableHandle> processTableVersion(Table table, QualifiedObjectName name, Optional<Scope> scope)
{
Expression stateExpr = table.getTableVersionExpression().get().getStateExpression();
Expand Down Expand Up @@ -2513,7 +2514,7 @@ private Scope processMaterializedView(
if (!owner.isPresent()) {
throw new SemanticException(NOT_SUPPORTED, "Owner must be present for DEFINER security mode");
}
queryIdentity = new Identity(owner.get(), Optional.empty(), session.getIdentity().getExtraCredentials());
queryIdentity = new Identity(owner.get(), Optional.empty(), emptyMap(), session.getIdentity().getExtraCredentials(), emptyMap(), Optional.empty(), session.getIdentity().getReasonForSelect(), emptyList());
// Use ViewAccessControl when the session user is not the owner, matching regular view behavior.
// This checks CREATE_VIEW_WITH_SELECT_COLUMNS permissions to prevent privilege escalation
// where a user with only SELECT could grant access to others via a DEFINER MV.
Expand Down Expand Up @@ -4303,7 +4304,7 @@ private RelationType analyzeView(Query query, QualifiedObjectName name, Optional
AccessControl viewAccessControl;
if (owner.isPresent() && !owner.get().equals(session.getIdentity().getUser())) {
// definer mode
identity = new Identity(owner.get(), Optional.empty(), session.getIdentity().getExtraCredentials());
identity = new Identity(owner.get(), Optional.empty(), emptyMap(), session.getIdentity().getExtraCredentials(), emptyMap(), Optional.empty(), session.getIdentity().getReasonForSelect(), emptyList());
viewAccessControl = new ViewAccessControl(accessControl);
}
else {
Expand Down
Loading