Skip to content

Apply session authentication to descriptor repositories by provenance - #13008

Draft
slachiewicz wants to merge 2 commits into
apache:masterfrom
slachiewicz:repo-provenance-auth-master
Draft

Apply session authentication to descriptor repositories by provenance#13008
slachiewicz wants to merge 2 commits into
apache:masterfrom
slachiewicz:repo-provenance-auth-master

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Repositories declared by a model that was resolved from a repository (a dependency POM, or a parent or import reached from one) are remotely supplied input, but they were aggregated with the same aggregate call as build-supplied repositories, so a <server> in settings.xml whose id matched a repository id in a downloaded POM had its credentials attached to that repository.

maven-resolver 2.0.23 (apache/maven-resolver#2090) adds an aggregateRepositories overload with a provenance flag: descriptor-declared repositories receive session authentication only when an operator-defined mirror captures them, and aether.remoteRepositoryManager.authToDescriptorRepositories=true restores the previous behaviour. This adds the matching five-argument RepositoryFactory.aggregate as a default method (delegating to the existing one, so other implementations are unaffected), passes the flag through DefaultRepositoryFactory, and sets it from DefaultModelBuilder's existing externalOrigin and from the compat DefaultModelResolver, which only builds descriptor models. ProjectModelResolver builds the project's own model and parents, which are operator-chosen, and keeps the four-argument call.

Blocked on the maven-resolver 2.0.23 release: the second commit bumps resolverVersion to 2.0.23-SNAPSHOT as a build aid and must be dropped, and the first commit does not compile against 2.0.22.

Verified: mvn -pl api/maven-api-core,impl/maven-impl,compat/maven-resolver-provider -am -Dmaven.test.skip install against 2.0.23-SNAPSHOT → compiles. The maven-impl test sources do not compile on current master independently of this change (DistributionManagementArtifactRelocationSourceTest.noRelocationReturnsNull calls a method that has declared ArtifactDescriptorException since #12950), so the module tests could not be run here.

This change was created with AI assistance.

Repositories declared by a model that was resolved from a repository (a
dependency POM, or a parent or import reached from one) are remotely
supplied input, but they were aggregated with the same call as
build-supplied repositories, so a settings server whose id matched a
repository id in a downloaded POM had its credentials attached to it.

maven-resolver 2.0.23 (apache/maven-resolver#2090) adds an
aggregateRepositories overload with a provenance flag. Add the matching
default-method overload to RepositoryFactory, pass the flag through
DefaultRepositoryFactory, and set it from DefaultModelBuilder's
externalOrigin and from the compat DefaultModelResolver, which only
builds descriptor models. The project's own model and parents keep the
existing call and keep receiving session authentication.
@slachiewicz
slachiewicz force-pushed the repo-provenance-auth-master branch from aaf4cb0 to 7a21be5 Compare September 1, 2026 23:01
@slachiewicz slachiewicz added bug Something isn't working mvn4 labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant