Repository navigation
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
Core logic is correct — moving authSelector.add() to after the headers loop is the right fix to include token headers in the built Authentication. Two points worth addressing before merge:
1. authSelector.add() skipped on malformed timeout value (behavior regression)
The PR moves authSelector.add(server.getId(), authBuilder.build()) from before the configuration block to after it. This means Integer.parseInt(connectTimeoutXml.getValue()) and Integer.parseInt(requestTimeoutXml.getValue()) now execute between building the auth and registering it. If a settings.xml has a non-numeric <connectTimeout> or <requestTimeout>, a NumberFormatException will propagate up and authSelector.add() will never be called — leaving the server without registered authentication. Previously the auth was registered unconditionally before config parsing, so malformed timeout values only broke the timeout configuration, not authentication itself.
Consider wrapping the timeout-parsing block in a try/catch, or move authSelector.add() to immediately after the headers loop (before the timeout block):
// Add to auth selector after token headers are wired in, before timeout parsing
authSelector.add(server.getId(), authBuilder.build());
PlexusConfiguration connectTimeoutXml = config.getChild("connectTimeout", false);
// ...2. Empty bearer token admitted silently
authBuilder.addBearerToken(value.substring("Bearer ".length()))If a user configures <value>Bearer </value> (the prefix with no actual token), substring returns "". addBearerToken("") calls addTokenHeader(AUTHORIZATION, "Bearer ") — a blank Authorization header will be sent to the repository, likely causing a 401. A guard would catch the misconfiguration early:
String token = value.substring("Bearer ".length());
if (!token.isEmpty()) {
authBuilder.addBearerToken(token);
}3. No test coverage for the new auth wiring
The new code path (token headers in Authentication) is security-sensitive and has zero test coverage. A unit test on DefaultRepositorySystemSessionFactory verifying that a Bearer <token> header in settings.xml ends up in the AuthenticationSelector would catch regressions without requiring a full integration setup.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
LGTM on the structural fix — moving authSelector.add() after the headers loop is the correct fix for the race where token headers would have been excluded from the built Authentication. The approach (reusing the existing <httpHeaders> path, delegating validation to isValidTokenHeaderName) is clean.
Two issues need attention before this can ship:
Missing test for the new auth-wiring path. The existing httpConfigurationWithHttpHeadersTest only asserts the HTTP_HEADERS config map — it does not verify that bearer/token headers are wired into the Authentication object. The new code path (addBearerToken/addTokenHeader) is completely untested.
Uncaught IllegalArgumentException from duplicate headers. AuthenticationBuilder.addTokenHeader/addBearerToken throw IllegalArgumentException if the same header name is added twice (case-insensitive — enforced by tokenValueKey()). A malformed settings.xml with two Authorization properties would propagate this exception uncaught through newRepositorySessionBuilder, crashing Maven startup with a stack trace rather than a user-friendly diagnostic.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| <plexusTestingVersion>2.2.0</plexusTestingVersion> | ||
| <plexusXmlVersion>4.2.1</plexusXmlVersion> | ||
| <resolverVersion>2.0.26</resolverVersion> | ||
| <resolverVersion>2.0.27-SNAPSHOT</resolverVersion> |
There was a problem hiding this comment.
💡 2.0.27-SNAPSHOT cannot ship in a Maven release. Update to 2.0.27 once apache/maven-resolver#2372 is released (the resolver PR was merged 2026-11-30 so the release should follow shortly).
|
The |
…th (apache#14203) Port of apache#14203 (maven-3.10.x) to master. Wire `<configuration><httpHeaders>` entries into `AuthenticationBuilder` token headers, so bearer tokens and custom HTTP authentication headers stored in `settings.xml` are: - Origin-scoped by the Resolver's `addBearerToken`/`addTokenHeader` path - RFC 9110 validated by `HttpTransporterUtils.isValidTokenHeaderName` - Moved `authSelector.add()` to after the headers loop so token headers are included in the built Authentication object No decryption change needed here: `DefaultSettingsBuilder` already decrypts all `configuration` XmlNode values via its `DecryptingSettingsTransformer`, which walks the DOM tree recursively. Requires maven-resolver 2.0.27-SNAPSHOT for `isValidTokenHeaderName`, `addBearerToken`, and `addTokenHeader`.
fe937dc to
0b046d9
Compare
|
Addressed the gnodet-bot findings and pushed updated branch:
The 2.0.27-SNAPSHOT dependency thread is left open pending the maven-resolver 2.0.27 release. |
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — the previous three findings are addressed:
- Empty bearer token guard (
!token.isEmpty()) ✅ IllegalArgumentExceptionon duplicate headers (try/catch withlogger.warn) ✅- Test coverage (3 tests in
DefaultRepositorySystemSessionFactoryTest, 3 inDefaultSettingsDecrypterTest) ✅ - Timeout parsing (
NumberFormatExceptioncaught withlogger.warn) ✅
One issue with this round:
PR description contradicts the actual diff. The "Difference from 3.10.x port" section states:
No change to
compat/maven-settings-builderor any decryption code needed here. The only changes are: (1)impl/maven-core—DefaultRepositorySystemSessionFactoryand (2)pom.xml.
The diff shows a third change: compat/maven-settings-builder/DefaultSettingsDecrypter.java now gains decryptHttpHeaders(). The compat change is functionally correct — Maven 3 embedders using the compat layer bypass DefaultSettingsBuilder and its DecryptingSettingsTransformer, so they would miss httpHeaders decryption without this addition. But the description is stale and will mislead future readers.
Additionally, per the compat-layer review rule, behaviour changes in compat/maven-settings-builder should be paired with the equivalent change already landed in Maven 3.x. The companion PR #14203 (maven-3.10.x port) is still open — the compat change here is ahead of the Maven 3.x port. This isn't a blocker if the sequencing is intentional, but it should be called out.
Please update the PR description to list the compat change as a third modification, and note the sequencing dependency on #14203.
The resolverVersion>2.0.27-SNAPSHOT blocker is already tracked in the open review thread.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Port of #14203 (
maven-3.10.x) tomaster.Summary
Wire
<configuration><httpHeaders>entries intoAuthenticationBuildertoken headers, so that bearer tokens and custom HTTP authentication headers stored insettings.xmlare:addBearerToken/addTokenHeaderpath, so tokens are never sent to cross-origin redirectsHttpTransporterUtils.isValidTokenHeaderNamebefore being added to theAuthenticationauthSelector.add()to after the headers loop so token headers are included in the builtAuthenticationobjectChanges
impl/maven-core—DefaultRepositorySystemSessionFactory: wire token headers from<configuration><httpHeaders>intoAuthenticationBuilder, with guards for empty bearer tokens, duplicate headers, and malformed timeout valuescompat/maven-settings-builder—DefaultSettingsDecrypter: adddecryptHttpHeaders()to decrypt<configuration><httpHeaders>property values in-place. Maven 3 embedders use the compat layer directly (bypassingDefaultSettingsBuilder'sDecryptingSettingsTransformer), so without this change encrypted httpHeaders values would not be decrypted when going through the compat path.pom.xml: bumpresolverVersionto2.0.27(required forisValidTokenHeaderName,addBearerToken,addTokenHeader)Difference from 3.10.x port (#14203)
The
impl/maven-impl'sDefaultSettingsBuilderalready decrypts allconfigurationXmlNode values via itsDecryptingSettingsTransformer, which walks the DOM tree recursively and callstransform(String)on every leaf value — includinghttpHeadersproperty values. This master port therefore needs an additional change incompat/maven-settings-builderto bring the same decryption to the Maven 3 compat layer.Licensed under the Apache License, Version 2.0. I confirm that my contribution is made under the terms of the Apache License Version 2.0.