Skip to content

Commit

Permalink
Pass cat token for view definer mode
Browse files Browse the repository at this point in the history
Currently for view definer mode in Presto, extra credentials such as
CAT tokens are not passed. This change ensures that all extra
credentials are passed in the view definer mode.
  • Loading branch information
jainxrohit committed Jan 12, 2024
1 parent e01dc52 commit 6b9f680
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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());
return new Identity(owner.get(), Optional.empty(), session.getIdentity().getExtraCredentials());
}
return session.getIdentity();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,7 @@ private RelationType analyzeView(Query query, QualifiedObjectName name, Optional
Identity identity;
AccessControl viewAccessControl;
if (owner.isPresent() && !owner.get().equals(session.getIdentity().getUser())) {
identity = new Identity(owner.get(), Optional.empty());
identity = new Identity(owner.get(), Optional.empty(), session.getIdentity().getExtraCredentials());
viewAccessControl = new ViewAccessControl(accessControl);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public Identity(String user, Optional<Principal> principal)
this(user, principal, emptyMap(), emptyMap(), emptyMap(), Optional.empty(), Optional.empty());
}

public Identity(String user, Optional<Principal> principal, Map<String, String> extraCredentials)
{
this(user, principal, emptyMap(), extraCredentials, emptyMap(), Optional.empty(), Optional.empty());
}

public Identity(
String user,
Optional<Principal> principal,
Expand Down

0 comments on commit 6b9f680

Please sign in to comment.