Configuring group mapping in Knox

Learn how to use HadoopGroupProvider to configure group mapping.

The role for this provider is identity-assertion and name is HadoopGroupProvider:
<provider>
   <role>identity-assertion</role>
   <name>HadoopGroupProvider</name>
   <enabled>true</enabled>
   <<param> ... </param>
</provider>
All the configurations for HadoopGroupProvider reside in the provider section of a gateway topology file. The hadoop.security.group.mapping property determines the implementation. Some of the valid implementations are as follows:
  • org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback

    This is the default implementation and is picked up if hadoop.security.group.mapping is not specified. This implementation determines if the Java Native Interface (JNI) is available. If JNI is available, the implementation uses the API to resolve a list of groups for a user. If JNI is not available then the shell implementation, org.apache.hadoop.security.ShellBasedUnixGroupsMapping is used. It shells out with the bash -c groups command (for a Linux/Unix environment) or the net group command (for a Windows environment) to resolve a list of groups for a user.

  • org.apache.hadoop.security.LdapGroupsMapping

    This implementation connects directly to an LDAP server to resolve the list of groups. However, this should only be used if the required groups reside exclusively in LDAP, and are not materialized on the Unix servers.

To enable group lookup using identity assertion as HadoopGroupProvider, perform the following steps:

  1. Go to Cloudera Manager > Knox > Configuration.
  2. Search for the Knox Gateway Advanced Configuration Snippet (Safety Valve) for conf/cdp-resources.xml property, and add the following entry:
    # name = providerConfigs:sso
    # value = role=federation#federation.name=SSOCookieProvider#federation.param.sso.authentication.provider.url=
    https://<knox_hostname>:8443/gateway/knoxsso/api/v1/websso#role=identity-assertion#identity-assertio...
    HadoopGroupProvider#identity-assertion.enabled=true#identity-assertion.param.CENTRAL_GROUP_CONFIG_PREFIX=gateway.group.
    config#role=authorization#authorization.name=XASecurePDPKnox#authorization.enabled=true
    The following is a sample demo of LDAP configurations for the LDAP setting:
    <param>
    
    <name>gateway.group.config.hadoop.security.group.mapping</name>
     <value>org.apache.hadoop.security.LdapGroupsMapping</value>
    
    </param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.bind.user</name>
     <value>uid=tom,ou=people,dc=hadoop,dc=apache,dc=org</value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.bind.password</name>
     <value>tom-password</value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.url</name>
     <value>ldap://localhost:33389</value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.base</name>
     <value></value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.search.filter.user</name>
     <value>(&amp;(|(objectclass=person)(objectclass=applicationProcess))(cn={0}))</value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.search.filter.group</name>
     <value>(objectclass=groupOfNames)</value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.search.attr.member</name>
     <value>member</value>
     </param>
     <param>
     <name>gateway.group.config.hadoop.security.group.mapping.ldap.search.attr.group.name</name>
     <value>cn</value>
     </param>
     </provider>
  3. Save your changes.
  4. Refresh the cluster.