lmccay commented on code in PR #1553:
URL: https://github.com/apache/knox/pull/1553#discussion_r4741640653


##########
.github/workflows/build/conf/topologies/knoxidf-provenance-denied.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with this
+work for additional information regarding copyright ownership. The ASF
+licenses this file to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<!--
+  KNOX-3623 (token-laundering defense, Option 2 - enforcement side). The 
KNOXIDF
+  /client registration endpoint refuses any caller whose token carries a
+  knox_token_provenance claim listed in
+  knoxidf.client.registration.denied.provenance.issuers. KNOXSSO is the 
provenance a
+  login token minted on knoxidf-ldap carries after a same-subject exchange on
+  knoxidf-token-provenance, so such a laundered token is refused here (HTTP 403
+  access_denied) while a token with no provenance claim (a plain minted token, 
or an
+  exchange output from a topology that does not stamp provenance) registers 
normally.
+  Empty/undefined (the default) denies no provenance.
+-->
+<topology>
+    <gateway>
+      <provider>
+         <role>federation</role>
+         <name>JWTProvider</name>
+         <enabled>true</enabled>
+         <param>
+            <name>knox.token.exp.server-managed</name>
+            <value>true</value>
+         </param>
+      </provider>
+      <provider>
+            <role>identity-assertion</role>
+            <name>Default</name>
+            <enabled>true</enabled>
+      </provider>
+    </gateway>
+
+    <service>
+        <role>KNOXIDF</role>
+        <param>
+            <name>knoxidf.knox.token.limit.per.user</name>
+            <value>-1</value>
+        </param>
+        <param>
+            <name>knoxidf.client.registration.denied.provenance.issuers</name>

Review Comment:
   I wonder whether have gateway-site.xml params for this would be a good idea. 
I think if we have a global setting that locks down invariants for a whole 
deployment then topology level to override that surgically would make a lot of 
sense. Otherwise, if you have many minting topologies, finding and configuring 
them all may be burdensome and error prone. What do you think?



##########
gateway-service-knoxidf/src/main/java/org/apache/knox/gateway/service/knoxidf/RegistrationResource.java:
##########
@@ -334,6 +359,19 @@ boolean delegatedCallerDenied() {
         return delegatedCallersDenied && 
SubjectUtils.getActorChainPrincipal(SubjectUtils.getCurrentSubject()) != null;
     }
 
+    /**
+     * @return {@code true} when the caller's token carries a 
knox_token_provenance claim (its exchange
+     * origin issuer) in the configured denied list -- blocking a login token 
laundered through a
+     * same-subject exchange into a registration-capable credential.
+     */
+    boolean provenanceDenied() {
+        if (deniedProvenanceIssuers.isEmpty()) {
+            return false;
+        }
+        final String provenance = 
SubjectUtils.getTokenProvenance(SubjectUtils.getCurrentSubject());
+        return provenance != null && 
deniedProvenanceIssuers.contains(provenance);

Review Comment:
   I think that is what
            return delegatedCallersDenied && 
SubjectUtils.getActorChainPrincipal(SubjectUtils.getCurrentSubject()) != null;
   
   below is for.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to