Skip to content

Commit

Permalink
Remove deprecated SystemAccessControl#checkCanSetSystemSessionProperty
Browse files Browse the repository at this point in the history
It was deprecated in 445 when a replacement method was added; I guess 10
versions is long enough for a transition period.
  • Loading branch information
ksobolew authored and wendigo committed Nov 8, 2024
1 parent 3f5df6f commit 71a0b9d
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,14 @@ default void checkCanWriteSystemInformation(Identity identity)
denyWriteSystemInformationAccess();
}

/**
* Check if identity is allowed to set the specified system property.
*
* @throws AccessDeniedException if not allowed
* @deprecated use {@link #checkCanSetSystemSessionProperty(Identity, QueryId, String)}
*/
@Deprecated
default void checkCanSetSystemSessionProperty(Identity identity, String propertyName)
{
denySetSystemSessionProperty(propertyName);
}

/**
* Check if identity is allowed to set the specified system property.
*
* @throws AccessDeniedException if not allowed
*/
default void checkCanSetSystemSessionProperty(Identity identity, QueryId queryId, String propertyName)
{
checkCanSetSystemSessionProperty(identity, propertyName);
denySetSystemSessionProperty(propertyName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public Collection<Identity> filterViewQueryOwnedBy(Identity identity, Collection
return queryOwners;
}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, String propertyName) {}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, QueryId queryId, String propertyName) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private boolean checkCanSystemInformation(Identity identity, SystemInformationRu
}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, String propertyName)
public void checkCanSetSystemSessionProperty(Identity identity, QueryId queryId, String propertyName)
{
boolean allowed = sessionPropertyRules.stream()
.map(rule -> rule.match(identity.getUser(), identity.getEnabledRoles(), identity.getGroups(), propertyName))
Expand All @@ -392,12 +392,6 @@ public void checkCanSetSystemSessionProperty(Identity identity, String propertyN
}
}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, QueryId queryId, String propertyName)
{
checkCanSetSystemSessionProperty(identity, propertyName);
}

@Override
public boolean canAccessCatalog(SystemSecurityContext context, String catalogName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ public void checkCanKillQueryOwnedBy(Identity identity, Identity queryOwner)
delegate().checkCanKillQueryOwnedBy(identity, queryOwner);
}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, String propertyName)
{
delegate().checkCanSetSystemSessionProperty(identity, propertyName);
}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, QueryId queryId, String propertyName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void checkCanWriteSystemInformation(Identity identity)
}

@Override
public void checkCanSetSystemSessionProperty(Identity identity, String propertyName)
public void checkCanSetSystemSessionProperty(Identity identity, QueryId queryId, String propertyName)
{
opaHighLevelClient.queryAndEnforce(
buildQueryContext(identity),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private void testIdentityResourceActions(
@Test
public void testStringResourceAction()
{
testStringResourceAction("SetSystemSessionProperty", "systemSessionProperty", (accessControl, systemSecurityContext, argument) -> accessControl.checkCanSetSystemSessionProperty(systemSecurityContext.getIdentity(), argument));
testStringResourceAction("SetSystemSessionProperty", "systemSessionProperty", (accessControl, systemSecurityContext, argument) -> accessControl.checkCanSetSystemSessionProperty(systemSecurityContext.getIdentity(), TEST_QUERY_ID, argument));
testStringResourceAction("CreateCatalog", "catalog", OpaAccessControl::checkCanCreateCatalog);
testStringResourceAction("DropCatalog", "catalog", OpaAccessControl::checkCanDropCatalog);
testStringResourceAction("ShowSchemas", "catalog", OpaAccessControl::checkCanShowSchemas);
Expand Down

0 comments on commit 71a0b9d

Please sign in to comment.