[ 
https://issues.apache.org/jira/browse/KNOX-2757?focusedWorklogId=778119&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-778119
 ]

ASF GitHub Bot logged work on KNOX-2757:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Jun/22 14:51
            Start Date: 03/Jun/22 14:51
    Worklog Time Spent: 10m 
      Work Description: zeroflag commented on code in PR #590:
URL: https://github.com/apache/knox/pull/590#discussion_r889018034


##########
gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderDeploymentContributor.java:
##########
@@ -62,46 +65,54 @@ protected String getFilterClassname() {
   }
 
   @Override
-  public void contributeFilter( DeploymentContext context, Provider provider, 
Service service,
-      ResourceDescriptor resource, List<FilterParamDescriptor> params ) {
-    Map<String, String> p = provider.getParams();
-    String prefix = p.get("CENTRAL_GROUP_CONFIG_PREFIX");
+  public void contributeFilter(DeploymentContext context, Provider provider, 
Service service, ResourceDescriptor resource, List<FilterParamDescriptor> 
params) {

Review Comment:
   What happens if we define the same property in gateway-site (via 
CENTRAL_GROUP_CONFIG_PREFIX) + in the provider config? If the provider config 
should take priority over the gateway-site config, is this handled by the patch?



##########
gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderDeploymentContributor.java:
##########
@@ -62,46 +65,54 @@ protected String getFilterClassname() {
   }
 
   @Override
-  public void contributeFilter( DeploymentContext context, Provider provider, 
Service service,
-      ResourceDescriptor resource, List<FilterParamDescriptor> params ) {
-    Map<String, String> p = provider.getParams();
-    String prefix = p.get("CENTRAL_GROUP_CONFIG_PREFIX");
+  public void contributeFilter(DeploymentContext context, Provider provider, 
Service service, ResourceDescriptor resource, List<FilterParamDescriptor> 
params) {
+    final List<FilterParamDescriptor> filterParams = params == null ? new 
ArrayList<>() : new ArrayList<>(params);
+
+    // add group mapping parameters from gateway-site.xml, if any
+    final List<FilterParamDescriptor> groupMappingParamsList = 
getParamsFromGatewaySiteWithCentralGroupConfigPrefix(provider, context, 
resource);
+    if (groupMappingParamsList != null && !groupMappingParamsList.isEmpty()) {

Review Comment:
   Minor: This check might be unnecessary since 
`getParamsFromGatewaySiteWithCentralGroupConfigPrefix` never returns nulls and 
nothing would happen if it was empty.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 778119)
    Time Spent: 20m  (was: 10m)

> Mutually exclusive filter params in the HadoopGroupProvider 
> identity-assertion provider
> ---------------------------------------------------------------------------------------
>
>                 Key: KNOX-2757
>                 URL: https://issues.apache.org/jira/browse/KNOX-2757
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.6.1
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Blocker
>             Fix For: 2.0.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> *Steps to reproduce:*
> 1. replace the {{Default}} identity-assertion provider in the {{sandbox}} 
> topology with this:
> {noformat}
>     <provider>
>         <role>identity-assertion</role>
>         <name>HadoopGroupProvider</name>
>         <enabled>true</enabled>
>         <param>
>             <name>CENTRAL_GROUP_CONFIG_PREFIX</name>
>             <value>gateway.group.config.</value>
>         </param>
>         <param>
>             <name>group.mapping.scientist</name>
>             <value>(!= 0 (size groups))</value>
>         </param>
>     </provider> {noformat}
> 2. wait until Knox redeploys the {{sandbox}} topology and check the generated 
> {{gateway.xml}} in the newly deployed web application
> *Actual results:*
> The {{group.mapping.scientist}} filter parameter is missing; only the params 
> in {{gateway-site.xml}} with the {{gateway.group.config.}} prefix were added:
> {noformat}
>         <filter>
>             <role>identity-assertion</role>
>             <name>HadoopGroupProvider</name>
>             
> <class>org.apache.knox.gateway.identityasserter.hadoop.groups.filter.HadoopGroupProviderFilter</class>
>             <param>
>                 
> <name>hadoop.security.group.mapping.ldap.search.attr.member</name>
>                 <value>member</value>
>             </param>
>             <param>
>                 
> <name>hadoop.security.group.mapping.ldap.search.filter.user</name>
>                 
> <value>(&amp;(|(objectclass=person)(objectclass=applicationProcess))(cn={0}))</value>
>             </param>
>             <param>
>                 
> <name>hadoop.security.group.mapping.ldap.search.attr.group.name</name>
>                 <value>cn</value>
>             </param>
>             <param>
>                 <name>hadoop.security.group.mapping.ldap.url</name>
>                 <value>ldap://localhost:33389</value>
>             </param>
>             <param>
>                 <name>hadoop.security.group.mapping</name>
>                 <value>org.apache.hadoop.security.LdapGroupsMapping</value>
>             </param>
>             <param>
>                 
> <name>hadoop.security.group.mapping.ldap.search.filter.group</name>
>                 <value>(objectclass=groupOfNames)</value>
>             </param>
>             <param>
>                 <name>hadoop.security.group.mapping.ldap.bind.user</name>
>                 <value>uid=guest,ou=people,dc=hadoop,dc=apache,dc=org</value>
>             </param>
>             <param>
>                 <name>hadoop.security.group.mapping.ldap.bind.password</name>
>                 <value>guest-password</value>
>             </param>
>         </filter>
> {noformat}
> *Expected results:*
> Both the pre-configured gateway-site.xml and the {{group.mapping.scientist}} 
> provider parameter should be added to the filter.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to