Skip to content

RANGER-5723: Plugin SPIFFE outbound auth for audit-server destination - #1139

Open
ramackri wants to merge 2 commits into
apache:masterfrom
ramackri:RANGER-5723-patch
Open

RANGER-5723: Plugin SPIFFE outbound auth for audit-server destination#1139
ramackri wants to merge 2 commits into
apache:masterfrom
ramackri:RANGER-5723-patch

Conversation

@ramackri

@ramackri ramackri commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Plugin outbound SPIFFE authentication for RANGER-5655 audit delivery.

JIRA: RANGER-5723

Split from closed #1135. Self-contained — compiles and tests against master without #1137.

Changes (7 files)

Area Files Purpose
SPIFFE utilities (common-utils) PluginHeaderAuthConfig, SpiffeIdentityResolver, tests Read audit XML auth props; resolve SPIFFE ID (value → file → env)
REST client (agents-common) RangerRESTClient.java setTrustedAuthHeaders() — apply X-Spiffe-Id on every outbound request
Audit destination RangerAuditServerDestination.java, test, pom.xml Wire SPIFFE headers on init when authn.header.enabled=true

Aligned with RANGER-5700 / #1096: auth is configured on the audit destination prefix, not per-plugin security XML.

Audit XML properties (plugin → ingestor)

Prefix: xasecure.audit.destination.auditserver

Property Required? Default Purpose
authn.header.enabled Yes (to enable) false Master switch
authn.header.spiffe No X-Spiffe-Id Header name for workload SPIFFE ID
authn.spiffe.value No (unset) Explicit SPIFFE ID (highest priority)
authn.spiffe.file No /var/run/secrets/spiffe.io/identity/spiffe SPIRE/agent identity file

Resolution order: authn.spiffe.valueauthn.spiffe.fileSPIFFE_ID env.

Minimum enable:

<property>
  <name>xasecure.audit.destination.auditserver.authn.header.enabled</name>
  <value>true</value>
</property>

Also required (unchanged): xasecure.audit.destination.auditserver=true and .url.

Safety: defaults to disabled; no install-template changes. E2E ingestor validation requires RANGER-5722 (AuditHeaderAuthFilter).

Related PRs

PR JIRA Scope
#1137 RANGER-5719 Partition plan library (parallel)
#1138 RANGER-5720 DB patch 078 (parallel)
This PR RANGER-5723 SPIFFE outbound for audit-server destination
(future) RANGER-5722 Ingestor inbound SPIFFE

Test plan

  • mvn -pl agents-audit/dest-auditserver -am test -Dtest=RangerAuditServerDestinationTest
  • mvn -pl common-utils test -Dtest=PluginHeaderAuthConfigTest
  • CI: build-17, plugins-docker-build

Add PluginHeaderAuthConfig, SpiffeIdentityResolver, and
RangerRESTClient.setTrustedAuthHeaders(); wire SPIFFE headers into
RangerAuditServerDestination when audit XML authn.header.enabled=true.
ramackri pushed a commit to ramackri/ranger that referenced this pull request Aug 6, 2026
…uting

Add agents-common partition plan model, allocator, validator, routing helpers,
and PolicyDownloadAuthUsersUtil for RANGER-5655. SPIFFE header utilities
move to RANGER-5723 (apache#1139).
@ramackri
ramackri force-pushed the RANGER-5723-patch branch from aa1a2e3 to 143fa62 Compare August 6, 2026 03:15
Drop configPrefixForServiceType, resolveEnabledConfigPrefix, and
RANGER_CONFIG_PREFIX; audit destination passes an explicit config prefix to
buildSpiffeAuthHeaders.
@ramackri
ramackri requested a review from kumaab August 7, 2026 17:15
Map<String, String> headers = new LinkedHashMap<>();

for (String headerName : headerNames) {
headers.put(headerName, spiffeId.trim());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spiffeId is already guaranteed trimmed by every path in SpiffeIdentityResolver.resolve() (value/file/env all go through StringUtils.trimToNull). The extra .trim() is dead code

}

if (StringUtils.isBlank(spiffeId)) {
LOG.warn("Plugin header auth enabled for {} but no SPIFFE ID could "

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at 91, 97 and 103 LOG.warn misconfiguration branches (missing header name, unresolved SPIFFE ID, malformed SPIFFE ID) aren't covered by PluginHeaderAuthConfigTest.

builder = builder.cookie(sessionId);
}

applyTrustedAuthHeaders(builder);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no test in the REST client test suite asserting the header actually lands on the outbound Invocation.Builder/request, current tests only validate header construction in PluginHeaderAuthConfig, not application. Worth one test verifying setTrustedAuthHeaders(...) results in the header being present on a built request

Comment on lines +102 to +106
Map<String, String> spiffeHeaders = PluginHeaderAuthConfig.buildSpiffeAuthHeaders(props, propPrefix);
if (!spiffeHeaders.isEmpty()) {
this.restClient.setTrustedAuthHeaders(spiffeHeaders);
LOG.debug("SPIFFE header authentication enabled for audit-server destination");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth a README note (or at least a code comment) on whether SPIFFE header auth is meant to be combined with the existing authn.type (JWT/Basic) config, since this is wired in unconditionally alongside whatever authType was configured above. If combining is intentional (defense-in-depth), a one-line comment would save the next reader from wondering; if it's meant to be mutually exclusive, might be worth validating/warning on conflicting config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants