Skip to content

Scope server credentials and validate legacy relocation coordinates - #12977

Draft
gnodet wants to merge 1 commit into
maven-4.0.xfrom
pr/legacy-compat-credential-scope-4.0.x
Draft

Scope server credentials and validate legacy relocation coordinates#12977
gnodet wants to merge 1 commit into
maven-4.0.xfrom
pr/legacy-compat-credential-scope-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Forward-port of #12954 from maven-3.10.x to maven-4.0.x, adapting all three fixes for the 4.0.x module structure and API differences:

  • OriginBoundAuthenticationSelector (new file in impl/maven-core): scopes server credentials to the declared origins (protocol, host, port) of repositories and mirrors configured in settings, preventing credential leakage to unrelated repositories. Supports three modes via maven.repository.credentialScope: origin (default), strict, and id (legacy).
  • Relocation coordinate validation (compat/maven-compat MavenMetadataSource): validates relocation groupId, artifactId, and version components before applying them, rejecting path traversal characters (/, \, ..) and control characters.
  • Exact server ID matching (compat/maven-compat DefaultWagonManager): uses equals instead of equalsIgnoreCase for server ID matching, consistent with LegacyRepositorySystem.injectAuthentication and the resolver's authentication selector.

Adaptations for 4.0.x

  • Module paths: maven-compat/ -> compat/maven-compat/, maven-core/ -> impl/maven-core/
  • OriginBoundAuthenticationSelector uses org.slf4j.Logger (4.0.x) instead of org.codehaus.plexus.logging.Logger (3.10.x)
  • Credential scope property read from mergedProps (4.0.x property flow) instead of ConfigUtils.getString(configProps, ...) (3.10.x)
  • MavenMetadataSourceRelocationTest uses constructor injection (4.0.x) instead of reflection-based field injection (3.10.x)

Test plan

  • mvn verify -pl impl/maven-core -- 602 tests pass, 0 failures
  • mvn verify -pl compat/maven-compat -- 156 tests pass, 0 failures
  • New OriginBoundAuthenticationSelectorTest covers: declared origin matching, origin scoping, undeclared ID legacy behavior, strict mode refusal, ID scope passthrough, unknown scope rejection, origin normalization
  • New MavenMetadataSourceRelocationTest covers: invalid artifactId rejection, well-formed relocation application

🤖 Generated with Claude Code

Forward-port of PR #12954 from maven-3.10.x to maven-4.0.x:

- OriginBoundAuthenticationSelector: scopes server credentials to
  declared origins (protocol, host, port) of repositories and mirrors,
  preventing credential leakage to unrelated repositories
- MavenMetadataSource: validates relocation coordinate components
  (groupId, artifactId, version) before applying them, rejecting
  path traversal characters and control characters
- DefaultWagonManager: uses exact server ID matching (equals instead
  of equalsIgnoreCase) consistent with LegacyRepositorySystem and the
  resolver's authentication selector

Adapted for 4.0.x module structure (compat/maven-compat, impl/maven-core)
and API differences (SLF4J logger, constructor injection, merged properties).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant