Skip to content

Credential scoping + relocation validation (3.9.x backport) - #13005

Merged
gnodet merged 4 commits into
maven-3.9.xfrom
pr/core-and-compat-3.9.x
Sep 2, 2026
Merged

Credential scoping + relocation validation (3.9.x backport)#13005
gnodet merged 4 commits into
maven-3.9.xfrom
pr/core-and-compat-3.9.x

Conversation

@gnodet

@gnodet gnodet commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of Fix Set B (credential scoping + relocation validation + server ID matching) to maven-3.9.x.

  • Validate relocation coordinates from resolved project metadata (reject path traversal, slashes, backslashes, colons, control characters in MavenMetadataSource)
  • Bind server credentials to declared repository origins (new OriginBoundAuthenticationSelector)
  • Match settings server IDs exactly (fix equalsIgnoreCaseequals in DefaultWagonManager)
  • Fix assertEquals(true, ...)assertTrue(...) in MavenMetadataSourceRelocationTest

Sibling PRs:

Note: DistributionManagementArtifactRelocationSource does not exist on 3.9.x (introduced in 3.10.x), so that file's validation is not included in this backport.

Test plan

  • MavenMetadataSourceRelocationTest covers relocation validation
  • OriginBoundAuthenticationSelectorTest covers credential scoping
  • CI build passes on maven-3.9.x

🤖 Generated with Claude Code

slachiewicz and others added 3 commits September 1, 2026 23:10
Credentials configured in settings for a server id are keyed only by
that id. A repository definition can also arrive from a POM resolved
out of a remote repository and reuse the id of a server the operator
holds credentials for, at a different origin than the one the operator
configured. Wrap the authentication selector so credentials for an id
are offered only to a repository whose origin (scheme, host, port)
matches a repository or mirror the operator declared, in settings or
on the command line, with that same id; other origins get a
once-per-id/origin warning naming the id and are refused.

Ids with no operator-declared repository (for example a deploy-only
server whose URL comes from the project's distributionManagement)
keep serving credentials as before, with a warning, so mvn deploy
using settings credentials plus a POM's distributionManagement keeps
working. The new maven.repository.credentialScope user property
selects the policy: "origin" (default), "strict" (also refuse
undeclared ids), or legacy "id".
Aligns the legacy WagonManager credential lookup with the exact-match semantics
used by every other id-keyed credential path; server ids have never been
documented as case-insensitive.
@gnodet
gnodet force-pushed the pr/core-and-compat-3.9.x branch from 0b7153b to fc899f9 Compare September 1, 2026 21:11
Remove unused imports left by rebase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well-adapted backport of credential scoping and server ID exact matching to 3.9.x. The OriginBoundAuthenticationSelector is identical to the 3.10.x version (correct, since it only depends on shared types). The DefaultRepositorySystemSessionFactory changes correctly target the 3.9.x API (DefaultRepositorySystemSession, Plexus Logger, wagon config keys).

One finding:

  • @since version tag (DefaultRepositorySystemSessionFactory.java:131): The @since tag on MAVEN_REPOSITORY_CREDENTIAL_SCOPE says 3.9.10, but Maven 3.9.10 was already released and does not contain this constant. The sibling PR #12954 correctly uses @since 3.10.0 for the 3.10.x branch. This should be @since 3.9.17 to match the next 3.9.x milestone.

Positive notes:

  • DefaultWagonManager change from equalsIgnoreCase to equals aligns with LegacyRepositorySystem.injectAuthentication (already case-sensitive via HashMap).
  • Relocation validation was already present on 3.9.x from a prior backport — correctly omitted from this diff.
  • DistributionManagementArtifactRelocationSource doesn't exist on 3.9.x — correctly omitted.
  • Credential scoping integration correctly adapts to DefaultRepositorySystemSession and aether.connector.perms config keys.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug
Milestone (none) 3.9.17

🤖 This review was generated by ForgeBot.

*
* @since 3.9.10
*/
public static final String MAVEN_REPOSITORY_CREDENTIAL_SCOPE = "maven.repository.credentialScope";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
public static final String MAVEN_REPOSITORY_CREDENTIAL_SCOPE = "maven.repository.credentialScope";
* @since 3.9.17

Maven 3.9.10 was already released and does not contain this constant. The sibling PR #12954 correctly uses @since 3.10.0. This should reference the next 3.9.x milestone (3.9.17).

@gnodet
gnodet merged commit aeb0a05 into maven-3.9.x Sep 2, 2026
21 checks passed
@gnodet
gnodet deleted the pr/core-and-compat-3.9.x branch September 2, 2026 06:16
@github-actions github-actions Bot added this to the 3.9.17 milestone Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

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