Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Table of Contents
 

Goals

  1. Authorize a subset of operations on CDAP entities using Apache Sentry

  2. Make the authorization system pluggable. Support the following two systems to begin with:

    1. Sentry based

    2. CDAP Dataset based

Checklist

  •  User stories documented (Rohit/Bhooshan)
  •  User stories reviewed (Nitin)
  •  Design documented (Rohit/Bhooshan)
  •  Design reviewed (Andreas)
  •  Feature merged (Rohit/Bhooshan)
  •  Examples and guides (Rohit)
  •  Integration tests (Bhooshan) 
  •  Documentation for feature (Rohit/Bhooshan)
  •  Blog post 

...

User Stories

  • As a CDAP system, I should be able to integrate with Apache Sentry for fine-grained role-based access controls of select CDAP operations 
  • As a CDAP admin, I should be able to easily configure Sentry to work with CDAP on different type of cluster (ex: CDH, CM cluster etc). 
  • As a CDAP admin, I should be able to create/update/delete roles in Apache Sentry
  • As a CDAP admin, I should be able to add users/groups to roles in Apache Sentry
  • As a CDAP admin, I should be able to turn authorization on/off easily for entire CDAP instance
  • As a CDAP system, I should be able to authorize the following requests
    • Namespace create/update/delete
    • Application deployment
    • Program start/stop
    • Stream read/write
      These operations are a subset that represents the various 'kinds' of operations allowed in CDAP

Scenarios

Scenario #1

  • D-Rock is an IT-Admin extra-ordinaire who has just been tasked with adding authorizing access to entities in CDAP on the cluster he manages. 
  • D-Rock is already familiar with Apache Sentry, since he has used it for authorization in other projects like Apache HDFS, Apache Hive, Apache Sqoop, etc. 
  • He would rather not learn a new authorization system. He would instead prefer that Apache Sentry be used to provide Role Based Access Control to CDAP entities as well.
  • As part of this, he would also like a streamlined installation and configuration experience with Apache Sentry and CDAP, including detailed instructions.

Scenario #2

  • D-Rock manages a variety of CDAP clusters in dev/smoke/qa/staging environments along with the prod environment.
  • For these environments, he would like to be able to turn authorization on/off easily with a switch for the CDAP instance, depending on the need at a given time.

Scenario #3

  • Ideally, D-Rock would like to be able to authorize all operations on all entities in CDAP. 
  • However, this can be rolled out in phases. In the initial phase, he would like to control who can:
    • Create/update/delete a namespace
      • Only users with WRITE permission on CDAP instance should be able to perform this operation.
      • A property in sentry-site.xml will decide a set of users who have admin permission on cdap instance. These admins can then later grant permissions to other users.
    • Deploy an application in a namespace
      • Only users with WRITE permission on the namespace should be able to perform this operation
      • One the application is deployed the the user who deployed becomes the ADMIN of the application. 
    • Start/stop a program
      • Only users with READ permission on the namespace and application, and EXECUTE permission on the program should be able to perform this operation
      • Only users with ADMIN permission on the program can set preference for the program
      • Only users with WRITE permission can provide runtime args
    • Read/write to a stream
      • Only users with READ privilege on the namespace and READ permission on the stream should be able to read from the stream
      • Only users with READ privilege on the namespace and WRITE permission on the stream should be able to write to the stream
      • Note: We have decided not to handle views separately. A user have same permission on all views of a stream as what it has on the stream. 

Entities, Operations and Privileges

...

 

Table of Contents
 

Goals

  1. Authorize a subset of operations on CDAP entities using Apache Sentry

  2. Make the authorization system pluggable. Support the following two systems to begin with:

    1. Sentry based

    2. CDAP Dataset based

Checklist

  •  User stories documented (Rohit/Bhooshan)
  •  User stories reviewed (Nitin)
  •  Design documented (Rohit/Bhooshan)
  •  Design reviewed (Andreas)
  •  Feature merged (Rohit/Bhooshan)
  •  Examples and guides (Rohit)
  •  Integration tests (Bhooshan) 
  •  Documentation for feature (Rohit/Bhooshan)
  •  Blog post 

...

User Stories

  • As a CDAP system, I should be able to integrate with Apache Sentry for fine-grained role-based access controls of select CDAP operations 
  • As a CDAP admin, I should be able to easily configure Sentry to work with CDAP on different type of cluster (ex: CDH, CM cluster etc). 
  • As a CDAP admin, I should be able to create/update/delete roles in Apache Sentry
  • As a CDAP admin, I should be able to add users/groups to roles in Apache Sentry
  • As a CDAP admin, I should be able to turn authorization on/off easily for entire CDAP instance
  • As a CDAP system, I should be able to authorize the following requests
    • Namespace create/update/delete
    • Application deployment
    • Program start/stop
    • Stream read/write
      These operations are a subset that represents the various 'kinds' of operations allowed in CDAP

Scenarios

Scenario #1

  • D-Rock is an IT-Admin extra-ordinaire who has just been tasked with adding authorizing access to entities in CDAP on the cluster he manages. 
  • D-Rock is already familiar with Apache Sentry, since he has used it for authorization in other projects like Apache HDFS, Apache Hive, Apache Sqoop, etc. 
  • He would rather not learn a new authorization system. He would instead prefer that Apache Sentry be used to provide Role Based Access Control to CDAP entities as well.
  • As part of this, he would also like a streamlined installation and configuration experience with Apache Sentry and CDAP, including detailed instructions.

Scenario #2

  • D-Rock manages a variety of CDAP clusters in dev/smoke/qa/staging environments along with the prod environment.
  • For these environments, he would like to be able to turn authorization on/off easily with a switch for the CDAP instance, depending on the need at a given time.

Scenario #3

  • Ideally, D-Rock would like to be able to authorize all operations on all entities in CDAP. 
  • However, this can be rolled out in phases. In the initial phase, he would like to control who can:
    • Create/update/delete a namespace
      • Only users with WRITE permission on CDAP instance should be able to perform this operation.
      • A property in sentry-site.xml will decide a set of users who have admin permission on cdap instance. These admins can then later grant permissions to other users.
    • Deploy an application in a namespace
      • Only users with WRITE permission on the namespace should be able to perform this operation
      • One the application is deployed the the user who deployed becomes the ADMIN of the application. 
    • Start/stop a program
      • Only users with READ permission on the namespace and application, and EXECUTE permission on the program should be able to perform this operation
      • Only users with ADMIN permission on the program can set preference for the program
      • Only users with WRITE permission can provide runtime args
    • Read/write to a stream
      • Only users with READ privilege on the namespace and READ permission on the stream should be able to read from the stream
      • Only users with READ privilege on the namespace and WRITE permission on the stream should be able to write to the stream
      • Note: We have decided not to handle views separately. A user have same permission on all views of a stream as what it has on the stream. 

Entities, Operations and Privileges

searchREAD NamespaceREAD (ArtifactADMIN (Application)EXECUTE get runtime argsREAD Program get instancesREAD Programset preferenceProgramget preferenceREAD Programget statusProgramget historyProgramStream propertiesStreamdeleteStreamStreamWRITE (StreamStreamlistNamespaceREAD (Stream
EntityOperationRequired PrivilegesResultant Privileges
NamespacecreateADMIN (Instance)ADMIN (Namespace)
 updateADMIN (Namespace) 
 listREAD (Instance) 
 getREAD (Namespace) 
 deleteADMIN (Namespace) 
 set preferenceWRITE (Namespace) 
 get preferenceREAD (Namespace) 
 searchREAD (Namespace) 
ArtifactaddWRITE (Namespace)ADMIN (Artifact)
 deleteADMIN (Artifact) 
 getREAD (Artifact) 
 listREAD (Namespace) 
 write propertyADMIN (Artifact) 
 delete propertyADMIN (Artifact) 
 get propertyREAD (Artifact) 
 refreshWRITE (Instance) 
 write metadataADMIN (Artifact) 
 read metadataREAD (Artifact) 
ApplicationdeployWRITE (Namespace)ADMIN (Application)
 getREAD (Application) 
 listREAD (Namespace) 
 updateADMIN (Application) ArtifactaddWRITE (Namespace)ADMIN (Artifact)
 deleteADMIN (ArtifactApplication) 
 getset preferenceREAD WRITE (ArtifactApplication) 
 listget preferenceREAD (NamespaceApplication) 
 write propertyadd metadataADMIN (ArtifactApplication) 
 delete propertyget metadataADMIN READ (ArtifactApplication)  get property
Programsstart/stop/debugEXECUTE (Program) 
 refreshset instancesWRITE ADMIN (InstanceProgram) 
 write metadatalistADMIN READ (ArtifactNamespace) 
 read metadataREAD (Artifactset runtime argsEXECUTE (Program) ApplicationdeployWRITE (Namespace)
 get runtime argsREAD (ApplicationProgram) 
 listget instancesREAD (NamespaceProgram) 
 updateset preferenceADMIN (ApplicationProgram) 
 deleteget preferenceADMIN READ (ApplicationProgram) 
 set preferenceget statusWRITE READ (ApplicationProgram) 
 get preferencehistoryREAD (ApplicationProgram) 
 add metadataADMIN (ApplicationProgram) 
 get metadataREAD (ApplicationProgram) Programs
start/stop/debug emit logsWRITE (question) (Program) 
 set instancesview logsADMIN READ (Program) 
 listemit metricsREAD WRITE (question) (NamespaceProgram) 
 set runtime argsEXECUTE view metricsREAD (Program)  
StreamscreateWRITE (Namespace)ADMIN (Stream)
 update propertiesADMIN (Stream) 
 deleteADMIN (Stream) 
 truncateADMIN (Stream) 
 enqueue
asyncEnqueue
batch
WRITE (Stream) 
 getREAD (Stream) 
 listREAD (Namespace) 
 read eventsREAD (Stream) 
 add metadataset preferencesADMIN (ProgramStream) 
 get preferencesREAD (Stream) 
 add metadataREAD ADMIN (ProgramStream) 
 emit logsWRITE (question) (Programget metadataREAD (Stream) 
 view logslineageREAD (ProgramStream) 
 emit metricsWRITE (question) (ProgramStream) 
 view metricsREAD (ProgramStream) 
StreamsDatasetslistREAD (Namespace) 
 getREAD (Dataset) 
 createWRITE (Namespace)ADMIN (Dataset)
 updateADMIN (Dataset) 
 dropADMIN (Dataset) 
 executeAdmin (exists/truncate/upgrade)ADMIN (Dataset) 
 enqueue
asyncEnqueue
batch
add metadataADMIN (Dataset) 
 get metadataREAD (Dataset) 
 view lineageREAD (Dataset) 
 read eventsemit metricsWRITE (question) (Dataset) 
 set preferencesview metricsADMIN READ (StreamDataset) 

NOTE: 

...

NOTE: Cells marked green are in scope for 3.4

Design

This feature can be broken down into the following main parts, in no specific order:

Authorization in CDAP

The authorization system in CDAP will be pluggable, and the backend can be provided by external systems like Apache Sentry/Ranger. It provides:

  • Authorization Enforcement hooks during various operations within CDAP, that throw AuthorizationException if the operation is not authorized.
  • ACL Management

This system exposes a set of interfaces defined below. 

AuthEnforcer

The AuthEnforcer interface provides a way to check if an operation is authorized. At various points in the CDAP code (NamespaceHttpHandler, AppLifecycleHttpHandler, ProgramLifecycleHttpHandler, StreamHandler in 3.4), this interface will be used to check if an operation is authorizedCells marked green are in scope for 3.4

Design

This feature can be broken down into the following main parts, in no specific order:

Authorization in CDAP

The authorization system in CDAP will be pluggable, and the backend can be provided by external systems like Apache Sentry/Ranger. It provides:

  • Authorization Enforcement hooks during various operations within CDAP, that throw AuthorizationException if the operation is not authorized.
  • ACL Management

This system exposes a set of interfaces defined below. 

AuthEnforcer

The AuthEnforcer interface provides a way to check if an operation is authorized. At various points in the CDAP code (NamespaceHttpHandler, AppLifecycleHttpHandler, ProgramLifecycleHttpHandler, StreamHandler in 3.4), this interface will be used to check if an operation is authorized.

Code Block
themeConfluence
languagejava
titleAuthChecker Interface
firstline1
linenumberstrue
interface AuthEnforcer {
	/**
     * Enforces authorization for the specified {@link Principal} for the specified {@link Action} on the specified {@link EntityId}.
     *
     * @param principal the principal that performs the actions. This could be a user, group or a role
     * @param entity the entity on which an action is being performed
     * @param action the action being performed
     * @throws AuthorizationException if the principal is not authorized to perform action on the entity
     */
	void enforce(Principal principal, EntityId entity, Action action) throws AuthorizationException;
}

Authorizer

This interface allows CDAP admins to grant/revoke permissions for specific operations on specific CDAP entities to specified Principals. It will be used by the ACL Management module, which may or may not reside in CDAP for the purposes of integration with Apache Sentry (question) TBD.

Code Block
themeConfluence
languagejava
titleAuthChecker Authorizer Interface
firstline1
linenumberstrue
interface Authorizer extends AuthEnforcer {
	/**
     * Grants a Enforcesprincipal authorization forto theperform specifieda {@linkset Principal}of foractions theon specifiedan {@linkentity.
Action} on the specified {@link EntityId}.*
     * @param entity the entity on which an action is being performed
     * @param principal the principalPrincipal that performs the actions. This could be a user, group or a role
     * @param entityactions the entityset onof whichactions an action is being performedto grant
     */
@param action the action beingvoid performedgrant(EntityId entity, Principal principal, Set<Action> actions);

	/**
@throws   AuthorizationException if the* principalGrants isa notPrincipal authorizedauthorization to perform actionall actions on thean entity.
     */
	void enforce(Principal principal, EntityId entity, Action action) throws AuthorizationException;
}

Authorizer

This interface allows CDAP admins to grant/revoke permissions for specific operations on specific CDAP entities to specified Principals. It will be used by the ACL Management module, which may or may not reside in CDAP for the purposes of integration with Apache Sentry (question) TBD.

Code Block
themeConfluence
languagejava
titleAuthorizer Interface
firstline1
linenumberstrue
interface Authorizer extends AuthEnforcer {
     * @param entity the entity on which an action is being performed
     * @param principal the Principal that performs the actions. This could be a user, group or a role
     */
    void grant(EntityId entity, Principal principal);
	/**
     * GrantsRevokes a principal's authorization to perform a set of actions on an entity.
     *
     * @param entity the entity on which an action is being performed
     * @param principal the Principalprincipal that performs the actions. This could be a user, group or a role
     * @param actions the set of actions to revoke permissions granton
     */
    void grantrevoke(EntityId entity, Principal principal, Set<Action> actions);

	/**
     * GrantsRevokes a Principalprincipal's authorization to perform allany actionsaction on an entity.
     *
     * @param entity the entity on which an action is being performed
     * @param principal the Principalprincipal that performs the actions. This could be a user, group or a role
     */
    void grantrevoke(EntityId entity, Principal principal);

    	/**
     * Revokes aall principalprincipals's authorization to perform a set of actionsany action on an entity.
     *
     * @param entity the entity on which an action is being performed
     */
@param  principal the principalvoid that performs the actions. This could be a user, group or a role
     * @param actions the set of actions to revoke permissions on
     */
    void revoke(EntityId entity, Principal principal, Set<Action> actions);

	/**
     * Revokes a principal's authorization to perform any action on an entity.
     *
     * @param entity the entity on which an action is being performed
     * @param principal the principal that performs the actions. This could be a user, group or a role
     */
    void revoke(EntityId entity, Principal principal);

    /**
     * Revokes all principals' authorization to perform any action on an entity.
     *
     * @param entity the entity on which an action is being performed
     */
    void revoke(EntityId entity);
}

...

revoke(EntityId entity);
}

Where Principal is the entity performing actions defined as below:

Code Block
themeConfluence
languagejava
titleSubject
firstline1
linenumberstrue
public class Principal {
	enum PrincipalType {
		USER,
		GROUP,
		ROLE
	}
 
	private final String name;
	private final PrincipalType type;
 
	public Principal(String name, PrincipalType type) {
		this.name = name;
		this.type = type;
	}
 
	public String getName() {
		return name;
	}
 
	public PrincipalType getType() {
		return type;
	}
}

Integration with Apache Sentry will be achieved by implementations of these interfaces that delegate to Apache Sentry.

Integration with Apache Sentry

Integration with Apache Sentry involves the development of three main modules:

CDAP Sentry Binding

Here we will bind CDAP to SentryGenericServiceClient and to the operations on the client.

Code Block
languagejava
titleSentryAuthorizer
public class SentryAuthorizer implements Authorizer {

    void grant(EntityId entity, Principal Principal, Set<Action> actions){
		// do grant operation on sentry client with needed mapping/conversion
	}
	... 
	...
	private SentryGenericServiceClient getClient() throws Exception {
	  return SentryGenericServiceClientFactory.create(conf); // create sentry client from Configuration 
	}
}

CDAP Sentry Model

The CDAP Sentry Model defines the CDAP entities for whom access needs to be authorized via Apache Sentry. It will based off of the Sentry Generic Authorization Model. The CDAP Sentry Model will have the following components:

CDAPAuthorizable

This interface defines the CDAP entities that need to be authorized. It must implement Authorizable.

Code Block
themeConfluence
languagejava
titleCDAPAuthorizable
firstline1
/**
 * This interface represents an authorizable resource in the CDAP component.
 */
public interface CDAPAuthorizable extends Authorizable {

  public enum AuthorizableType {
	Instance,
    Namespace,
    Artifact,
    Application,
    Program,
    Dataset,
    Stream,
  };
  AuthorizableType getAuthzType();
}

The CDAPAuthorizable interface will have to be implemented for each authorizable entity defined by the AuthorizableType enum above.

CDAPAction and CDAPActionFactory

These classes will implement BitFieldAction and BitFieldActionFactory to define the types of actions on CDAP entities. These classes also allow you to define implies relationships between actions.

TODO: Think about ALL, ADMIN_ALL

Code Block
themeConfluence
languagejava
titleSubjectCDAPActions
firstline1
linenumberstrue
public class PrincipalCDAPActionConstants {
	enum PrincipalType {
		USER,
		GROUP,
		ROLE
	}
 
	private final String name;
	private final PrincipalType type;
 
	public Principal(String name, PrincipalType type) {
		this.name = name;
		this.type = type;
	}
 
	public String getName() {
		return name;
	}
 
	public PrincipalType getType() {
		return type;
	}
}

Integration with Apache Sentry will be achieved by implementations of these interfaces that delegate to Apache Sentry.

Integration with Apache Sentry

Integration with Apache Sentry involves the development of three main modules:

CDAP Sentry Binding

Here we will bind CDAP to SentryGenericServiceClient and to the operations on the client.

Code Block
languagejava
titleSentryAuthorizer
public class SentryAuthorizer implements Authorizer {

    void grant(EntityId entity, Principal Principal, Set<Action> actions){
		// do grant operation on sentry client with needed mapping/conversion
	}
	... 
	...
	private SentryGenericServiceClient getClient() throws Exception {
	  return SentryGenericServiceClientFactory.create(conf); // create sentry client from Configuration 
	}
}

CDAP Sentry Model

The CDAP Sentry Model defines the CDAP entities for whom access needs to be authorized via Apache Sentry. It will based off of the Sentry Generic Authorization Model. The CDAP Sentry Model will have the following components:

CDAPAuthorizable

This interface defines the CDAP entities that need to be authorized. It must implement Authorizable.

Code Block
themeConfluence
languagejava
titleCDAPAuthorizable
firstline1
/**
 * This interface represents an authorizable resource in the CDAP component.
 */
public interface CDAPAuthorizable extends Authorizable {

  public enum AuthorizableType {
	Instance,
    Namespace,
    Artifact,
    Application,
    Program,
    Dataset,
    Stream,
  };
  AuthorizableType getAuthzType();
}

The CDAPAuthorizable interface will have to be implemented for each authorizable entity defined by the AuthorizableType enum above.

CDAPAction and CDAPActionFactory

These classes will implement BitFieldAction and BitFieldActionFactory to define the types of actions on CDAP entities. These classes also allow you to define implies relationships between actions.

TODO: Think about ALL, ADMIN_ALL

Code Block
themeConfluence
languagejava
titleCDAPActions
firstline1
linenumberstrue
public class CDAPActionConstants {
  public static final String READ = "read";
  public static final String EXECUTE = "execute";
  public static final String WRITE = "write";
  public static final String ADMIN = "admin"; // this is read + write + execute + admin (create/update/delete)
}

Sentry Policy Engine

Resource URIs

Using the above authorizable model, resource URIs for CDAP entities in the Sentry Policy Engine will be as follows:

EntitySentry Resource URI
Instance
cdap:///instance=server1
Namespacecdap:///instance=server1/namespace=ns1
Artifactcdap:///instance=server1/namespace=ns1/artifact=art1
Application

cdap:///instance=server1/namespace=ns1/application=app1

Programcdap:///instance=server1/namespace=ns1/application=app1/programType=pt1/programName=prg1
Datasetcdap:///instance=server1/namespace=ns1/dataset=ds1
Streamcdap:///instance=server1/namespace=ns1/stream=s1
Note

The above URIs are internal Apache Sentry representations defined at SentryAuthorizationModelDesign. They are only mentioned here to convey how the CDAP entity hierarchy will be represented in Apache Sentry.

Interaction Diagram

Use-case: App Deployment by an unauthorized user

Image Removed

Configuration

Sentry

PropertyDescriptionValue
sentry.service.allow.connectList of users allowed to connect to the Sentry Servercdap will be added to this list
sentry.cdap.provider
Authorization provider for the CDAP component in Sentry. This class defines the user-group mapping amongst other things.
org.apache.sentry.provider.common.
HadoopGroupResourceAuthorizationProvider
sentry.cdap.provider.resourceThe resource for creating the Sentry Provider Backend. This property seems unused, and always defaults to "". However, all data engines (hive, sqoop, kafka define it).""
sentry.cdap.provider.backendA class that implements ProviderBackend. This class uses a SentryServiceClient to communicate with the sentry service from the client side in Sentry.
org.apache.sentry.provider.db.generic.SentryGenericProviderBackend
sentry.cdap.policy.engineDefines the Sentry Policy Engine for the cdap component. Must implement org.apache.sentry.policy.common.PolicyEngine

co.cask.cdap.security.authorization.sentry.policy.PolicyEngine

(package name subject to change)

sentry.cdap.instance.nameDefines the instance name for the cdap component.cdap

CDAP

These properties will be defined in cdap-security.xml

PropertyDescriptionDefault
security.authorization.enabled
Determines whether authorization should be enabled in CDAP. If false, a NoOpAuthorizer would be used for security.authorizer.classfalse
security.authorizer.class
Fully qualified class name of the authorizer class. Must implement the Authorizer interfaceco.cask.cdap.security.authorization.DatasetBasedAuthorizer

Role Management

To support RBAC (Role Based Access Control) such as Apache Sentry we will need to support role management through CDAP.

A user using RBAC should be able to:

  • Create a role
  • delete a role
  • add role to principal (where principal can be of type user or group)
  • remove role from a principal (where principal can be of type user or group)
  • List roles
  • List roles for principal
  • List privileges for role

We will need to support this operation from through REST  APIs and also through cli. Below is the proposed APIs and CLI commands:

 

OperationREST APIBodyResponseCLI Command (from Security CLI commands)
create role

PUT /security/authorization/roles/<role-name>

N/A

200: Created the role

409: role already exists

 
create role <role-name>
delete roleDELETE /security/authorization/roles/<role-name>N/A

200: Deleted the role

404: role is not found

 
drop role <role-name>
List rolesGET /security/authorization/roles/N/A

200: List of roles

Code Block
titleRoles
["Role", "Role2"]
list roles
add role to principalPUT /security/authorization/<principal-type>/<principal-name>/roles/<role-name>

 

200: Added role to principal

404: role not found

404: principal not found

 
add role <role-name> to group/user <group/user-name>
remove role from principalDELETE /security/authorization/<principal-type>/<principal-name>/roles/<role-name>

 

200: removed role from principal

404: role not found

404: principal not found

 
remove role <role-name> from group/user <group/user-name>
List roles for principalGET /security/authorization/<principal-type>/<principal-name>/roles

N/A

 200: List of roles

Code Block
titleRoles
["Role", "Role2"]

404: Principal not found

list roles for group/user <group/user-name>
 List privileges for roleGET /security/authorization/roles/<role-name>/privilegesN/A 

 200: List of privileges for the role

Code Block
titlePrivileges
["Privilege1", "Privilege2"]

404: role not found

list privileges for role <role-name>

 

...

public static final String READ = "read";
  public static final String EXECUTE = "execute";
  public static final String WRITE = "write";
  public static final String ADMIN = "admin"; // this is read + write + execute + admin (create/update/delete)
}

Sentry Policy Engine

Resource URIs

Using the above authorizable model, resource URIs for CDAP entities in the Sentry Policy Engine will be as follows:

EntitySentry Resource URI
Instance
cdap:///instance=server1
Namespacecdap:///instance=server1/namespace=ns1
Artifactcdap:///instance=server1/namespace=ns1/artifact=art1
Application

cdap:///instance=server1/namespace=ns1/application=app1

Programcdap:///instance=server1/namespace=ns1/application=app1/programType=pt1/programName=prg1
Datasetcdap:///instance=server1/namespace=ns1/dataset=ds1
Streamcdap:///instance=server1/namespace=ns1/stream=s1
Note

The above URIs are internal Apache Sentry representations defined at SentryAuthorizationModelDesign. They are only mentioned here to convey how the CDAP entity hierarchy will be represented in Apache Sentry.

Interaction Diagram

Use-case: App Deployment by an unauthorized user

Image Added

Configuration

Sentry

PropertyDescriptionValue
sentry.service.allow.connectList of users allowed to connect to the Sentry Servercdap will be added to this list
sentry.cdap.provider
Authorization provider for the CDAP component in Sentry. This class defines the user-group mapping amongst other things.
org.apache.sentry.provider.common.
HadoopGroupResourceAuthorizationProvider
sentry.cdap.provider.resourceThe resource for creating the Sentry Provider Backend. This property seems unused, and always defaults to "". However, all data engines (hive, sqoop, kafka define it).""
sentry.cdap.provider.backendA class that implements ProviderBackend. This class uses a SentryServiceClient to communicate with the sentry service from the client side in Sentry.
org.apache.sentry.provider.db.generic.SentryGenericProviderBackend
sentry.cdap.policy.engineDefines the Sentry Policy Engine for the cdap component. Must implement org.apache.sentry.policy.common.PolicyEngine

co.cask.cdap.security.authorization.sentry.policy.PolicyEngine

(package name subject to change)

sentry.cdap.instance.nameDefines the instance name for the cdap component.cdap

CDAP

These properties will be defined in cdap-security.xml

PropertyDescriptionDefault
security.authorization.enabled
Determines whether authorization should be enabled in CDAP. If false, a NoOpAuthorizer would be used for security.authorizer.classfalse
security.authorizer.class
Fully qualified class name of the authorizer class. Must implement the Authorizer interfaceco.cask.cdap.security.authorization.DatasetBasedAuthorizer

Role Management

To support RBAC (Role Based Access Control) such as Apache Sentry we will need to support role management through CDAP.

A user using RBAC should be able to:

  • Create a role
  • delete a role
  • add role to principal (where principal can be of type user or group)
  • remove role from a principal (where principal can be of type user or group)
  • List roles
  • List roles for principal
  • List privileges for role

We will need to support this operation from through REST  APIs and also through cli. Below is the proposed APIs and CLI commands:

Authorization API

Security CLI commands

ACL management

There are multiple options for ACL Management. For dataset-based authorizer, we will have to support ACL Management via the CDAP CLI.

...