mneethiraj commented on code in PR #1139:
URL: https://github.com/apache/ranger/pull/1139#discussion_r3790272619
##########
agents-audit/dest-auditserver/src/main/java/org/apache/ranger/audit/destination/RangerAuditServerDestination.java:
##########
@@ -98,6 +99,14 @@ public void init(Properties props, String propPrefix) {
this.restClient.setMaxRetryAttempts(maxRetryAttempts);
this.restClient.setRetryIntervalMs(retryIntervalMs);
+ // SPIFFE header auth is orthogonal to authn.type
(JWT/Basic/Kerberos): when enabled,
+ // trusted headers are added in addition to whatever authType
configured above.
+ Map<String, String> spiffeHeaders =
PluginHeaderAuthConfig.buildSpiffeAuthHeaders(props, propPrefix);
Review Comment:
I suggest replacing references to `Spiffe` with `Trusted` - like
`buildSpiffeAuthHeaders()` => `buildTrustedAuthHeaders()`
##########
common-utils/src/main/java/org/apache/ranger/plugin/util/PluginHeaderAuthConfig.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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
+ * 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.plugin.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Outbound trusted-header auth for audit-server and other REST clients.
+ *
+ * <p>Properties are read under a caller-supplied prefix (audit destination
example):
+ * <pre>
+ * xasecure.audit.destination.auditserver.authn.header.enabled=true
+ * xasecure.audit.destination.auditserver.authn.header.spiffe=X-Spiffe-Id
Review Comment:
Instead of hardcoding for specific Spiffe headers, consider getting list of
headers via configurations, like:
```
authn.header.enabled=true
authn.header.headers=spiffie,value
authn.header.spiffie=X-Spiffe-Id
authn.header.value=file:/path/to/spiffe-id.file
# valid values:
# file:file:/path/to/spiffe-id.file
# env:SPIFFE_ID
# string value
```
--
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]