mneethiraj commented on code in PR #1139:
URL: https://github.com/apache/ranger/pull/1139#discussion_r3792104214
##########
common-utils/src/main/java/org/apache/ranger/plugin/util/PluginHeaderAuthConfig.java:
##########
@@ -33,23 +33,35 @@
/**
* Outbound trusted-header auth for audit-server and other REST clients.
*
- * <p>Legacy SPIFFE configuration (audit destination example):
+ * <p>When {@code authn.header.enabled=true}, trusted HTTP headers are added
to every
+ * outbound REST request. Header names and values are resolved from
configuration under
+ * a caller-supplied prefix (audit destination example below).
+ *
+ * <p>Legacy mode (no {@code authn.header.headers}): a single SPIFFE
workload-identity
+ * header is built from {@code authn.header.spiffe} (HTTP header name, default
+ * {@code X-Spiffe-Id}) and a SPIFFE ID resolved by {@link
SpiffeIdentityResolver}
+ * ({@code authn.spiffe.value}, {@code authn.spiffe.file}, or {@code
SPIFFE_ID} env).
* <pre>
* xasecure.audit.destination.auditserver.authn.header.enabled=true
* xasecure.audit.destination.auditserver.authn.header.spiffe=X-Spiffe-Id
* xasecure.audit.destination.auditserver.authn.spiffe.value=spiffe://...
* </pre>
*
- * <p>Generic slot-based configuration:
+ * <p>Generic slot-based mode ({@code authn.header.headers} set): header names
and
+ * values are read from {@code authn.header.{slot}} properties. Value specs
support
+ * {@code file:}, {@code env:}, or a literal string.
* <pre>
- * authn.header.enabled=true
- * authn.header.headers=spiffe,value
- * authn.header.spiffe=X-Spiffe-Id
- * authn.header.value=file:/path/to/spiffe-id.file
+ * xasecure.audit.destination.auditserver.authn.header.enabled=true
+ * xasecure.audit.destination.auditserver.authn.header.headers=spiffe,value
Review Comment:
I suggested this configuration approach earlier; however, I think the
following is better, as this eliminates the need for `headers` property. Please
review:
```
xasecure.audit.destination.auditserver.authn.header.enabled=true
xasecure.audit.destination.auditserver.authn.header.X-Spiffe-Id=file:/path/to/spiffe-id.file
# valid values:
# file:/path/to/spiffe-id.file
# env:SPIFFE_ID
# spiffe://trust-domain/ns/.../sa/... (literal string)
```
##########
common-utils/src/main/java/org/apache/ranger/plugin/util/PluginHeaderAuthConfig.java:
##########
@@ -33,23 +33,35 @@
/**
* Outbound trusted-header auth for audit-server and other REST clients.
*
- * <p>Legacy SPIFFE configuration (audit destination example):
+ * <p>When {@code authn.header.enabled=true}, trusted HTTP headers are added
to every
+ * outbound REST request. Header names and values are resolved from
configuration under
+ * a caller-supplied prefix (audit destination example below).
+ *
+ * <p>Legacy mode (no {@code authn.header.headers}): a single SPIFFE
workload-identity
Review Comment:
@ramackri - there is no "Legacy mode", given this feature is introduced
with this PR. Please remove lines 40 to 43; also review and remove other such
references.
##########
agents-audit/dest-auditserver/src/test/java/org/apache/ranger/audit/destination/RangerAuditServerDestinationTest.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.audit.destination;
+
+import org.apache.ranger.plugin.util.PluginHeaderAuthConfig;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class RangerAuditServerDestinationTest {
+ private static final String AUDIT_DEST_PREFIX =
"xasecure.audit.destination.auditserver";
+
+ @Test
+ public void buildTrustedAuthHeadersUsesAuditDestinationPrefix() {
+ Properties props = new Properties();
+ props.setProperty(AUDIT_DEST_PREFIX + ".authn.header.enabled", "true");
+ props.setProperty(AUDIT_DEST_PREFIX + ".authn.header.spiffe",
"X-Spiffe-Id");
Review Comment:
Headers are not aligned with the current approach; please review and update.
##########
agents-audit/dest-auditserver/src/test/java/org/apache/ranger/audit/destination/RangerAuditServerDestinationTest.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.audit.destination;
+
+import org.apache.ranger.plugin.util.PluginHeaderAuthConfig;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class RangerAuditServerDestinationTest {
+ private static final String AUDIT_DEST_PREFIX =
"xasecure.audit.destination.auditserver";
+
+ @Test
+ public void buildTrustedAuthHeadersUsesAuditDestinationPrefix() {
+ Properties props = new Properties();
+ props.setProperty(AUDIT_DEST_PREFIX + ".authn.header.enabled", "true");
+ props.setProperty(AUDIT_DEST_PREFIX + ".authn.header.spiffe",
"X-Spiffe-Id");
+ props.setProperty(AUDIT_DEST_PREFIX + ".authn.spiffe.value",
+ "spiffe://example.com/ns/default/sa/hive");
+
+ Map<String, String> headers =
PluginHeaderAuthConfig.buildTrustedAuthHeaders(props, AUDIT_DEST_PREFIX);
+
+ assertEquals(1, headers.size());
+ assertEquals("spiffe://example.com/ns/default/sa/hive",
headers.get("X-Spiffe-Id"));
+ }
+
+ @Test
+ public void buildTrustedAuthHeadersEmptyWhenAuditDestinationDisabled() {
+ Properties props = new Properties();
+ props.setProperty(AUDIT_DEST_PREFIX + ".authn.header.enabled",
"false");
Review Comment:
Headers are not aligned with the current approach; please review and update.
--
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]