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


##########
gateway-service-knoxidf/src/main/java/org/apache/knox/gateway/service/knoxidf/RegistrationResource.java:
##########
@@ -180,6 +201,10 @@ public Response registerClient(@FormParam("redirect_uris") 
String redirectUris,
                 detail = "reason=delegated_caller_denied";
                 return error("access_denied", "A delegated token cannot 
register a client.");
             }
+            if (provenanceDenied()) {

Review Comment:
   Fixed in ebdacd329. The guard the inherited token endpoints already used for 
delegated callers now also refuses a denied provenance, with 403 
`access_denied` and audit reason `provenance_denied`. That covers 
`getUserTokens`, `revoke`, `revokeTokens`, `enable`, `enableTokens`, `disable` 
and `disableTokens`, with unit tests per endpoint and an E2E test.



##########
.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:
   Agreed, done in ebdacd329. 
`gateway.knox.token.exchange.provenance.claim.enabled` in gateway-site.xml sets 
the deployment-wide default (false). A topology that sets 
`token.exchange.provenance.claim.enabled` overrides it either way. That way 
stamping can be switched on for every exchange topology at once and turned off 
surgically.
   
   I left the deny-list 
(`knoxidf.client.registration.denied.provenance.issuers`) topology-level, since 
it lives on the registration topology and there's typically only one of those. 
Happy to add a global default for it too if you think it's worthwhile.



-- 
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