Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission model clean-up #13455

Merged
merged 1 commit into from
Jun 18, 2021
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 @@ -64,7 +64,7 @@
import io.cdap.cdap.security.auth.context.AuthenticationContextModules;
import io.cdap.cdap.security.authorization.AuthorizationEnforcementModule;
import io.cdap.cdap.security.authorization.AuthorizationTestModule;
import io.cdap.cdap.security.authorization.InMemoryAuthorizer;
import io.cdap.cdap.security.authorization.InMemoryAccessController;
import io.cdap.cdap.security.impersonation.DefaultOwnerAdmin;
import io.cdap.cdap.security.impersonation.OwnerAdmin;
import io.cdap.cdap.security.impersonation.UGIProvider;
Expand Down Expand Up @@ -147,7 +147,7 @@ protected static void initialize(CConfiguration cConf, TemporaryFolder tmpFolder
Configuration hConf = new Configuration();
if (enableAuthorization) {
LocationFactory locationFactory = new LocalLocationFactory(tmpFolder.newFolder());
Location authExtensionJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class);
Location authExtensionJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAccessController.class);
cConf.setBoolean(Constants.Security.ENABLED, true);
cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authExtensionJar.toURI().getPath());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
*/
public class AuthorizationPrivilege {
private final EntityId entityId;
//Will only be set from GSON. Also will automatically be converted to permissions by PermissionAdapterFactory
private final Set<Permission> actions;
private final Set<Permission> permissions;
private final Principal principal;
private final EntityType childEntityType;
Expand All @@ -44,7 +42,6 @@ public AuthorizationPrivilege(Principal principal, EntityId entityId, Set<? exte
this.entityId = entityId;
this.permissions = Collections.unmodifiableSet(permissions);
this.childEntityType = childEntityType;
this.actions = null;
this.principal = principal;
}

Expand All @@ -59,12 +56,6 @@ public EntityId getEntity() {
public Set<Permission> getPermissions() {
return permissions;
}

@Nullable
public Set<? extends Permission> getActions() {
return actions;
}

/**
* @return child entity type for {@link AccessEnforcer#enforceOnParent(EntityType, EntityId, Principal, Permission)}
* checks.
Expand All @@ -85,7 +76,7 @@ public boolean equals(Object o) {
AuthorizationPrivilege that = (AuthorizationPrivilege) o;
return Objects.equals(entityId, that.entityId) && permissions.equals(that.permissions) &&
Objects.equals(childEntityType, that.childEntityType) &&
Objects.equals(actions, that.actions) && Objects.equals(principal, that.principal);
Objects.equals(principal, that.principal);
}

@Override
Expand All @@ -97,7 +88,6 @@ public int hashCode() {
public String toString() {
return "AuthorizationPrivilege {" +
"entityId=" + entityId +
", actions=" + actions +
", permissions=" + permissions +
", principal=" + principal +
", childEntityType=" + childEntityType +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,6 @@ public abstract class AbstractAccessEnforcer implements AccessEnforcer {
this.securityAuthorizationEnabled = AuthorizationUtil.isSecurityAuthorizationEnabled(cConf);
}

@Override
public void enforce(EntityId entity, Principal principal, Set<? extends Permission> permissions)
throws AccessException {
if (!isSecurityAuthorizationEnabled()) {
return;
}

Set<Permission> disallowed = new HashSet<>();
UnauthorizedException unauthorizedException = new UnauthorizedException(principal, entity);
for (Permission permission : permissions) {
try {
enforce(entity, principal, permission);
} catch (UnauthorizedException e) {
disallowed.add(permission);
unauthorizedException.addSuppressed(e);
}
}
if (!disallowed.isEmpty()) {
throw new UnauthorizedException(principal, disallowed, entity, unauthorizedException);
}
}

protected boolean isSecurityAuthorizationEnabled() {
return securityAuthorizationEnabled;
}
Expand Down
Loading