GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Issue #13265: let a settings server declare the repository origins its credentials may be used with by slawekjaranowski · Pull Request #13275 · apache/maven

Conversation

@slawekjaranowski

@slawekjaranowski slawekjaranowski commented Sep 26, 2026

Copy link
Copy Markdown
Member

Same change as #13268, for the maven-3.10.x branch.

Problem

Credentials of a <server> are bound to the origin (scheme, host, port) of the repositories and mirrors declared with the same id (maven.repository.credentialScope, default origin, since 3.10.0). declaredRepositoryOrigins is built in DefaultRepositorySystemSessionFactory from the mirrors and from request.getRemoteRepositories() / getPluginArtifactRepositories().

Repositories declared inside a settings.xml <profile> only reach those lists when the profile id is listed in <settings><activeProfiles>. A profile activated through <activation> (property, jdk, os, file) or through -P contributes no origin at all, so a perfectly legitimate corporate repository gets:

  • under the default origin scope: a warning on every build, with no way to silence it;
  • under strict: refused credentials and a 401.

This cannot be fixed automatically: the repository system session is created before any project is read, and profile activation is resolved later, per project, by the model builder.

Solution

A <server> can declare the origins its credentials may be used with:

<server>
  <id>internal</id>
  <username>u</username>
  <password>p</password>
  <repositoryOrigins>
    <repositoryOrigin>https://repo.example.org</repositoryOrigin>
    <repositoryOrigin>https://mirror.example.org:8443</repositoryOrigin>
  </repositoryOrigins>
</server>
  • Union, not replacement — declared origins are added to the ones Maven discovers itself, so existing configurations are unaffected.
  • Bare origins, not repository URLs. They go through the same normalization as every other origin: case-insensitive, :80/:443 equivalent to no port. Values are checked by settings validation, so a typo is reported where it is written rather than surfacing later as a refused credential. Values holding a property placeholder are skipped, since settings validation runs before interpolation.
  • The warnings emitted by the origin binding now name <repositoryOrigins> as the place to declare a missing origin, so the message is actionable.

Differences from #13268

  • No V4 counterpart here: this branch has a single settings model and a single settings validator.
  • The project settings part of Issue #13265: let a settings server declare the repository origins its credentials may be used with #13268 has no equivalent: Maven 3.x has no .mvn/settings.xml, so there is nothing to scrub.
  • maven-core had no test for DefaultRepositorySystemSessionFactory on this branch, so the credential scoping tests come as a new DefaultRepositorySystemSessionFactoryTest.

mvn verify is green on the whole repository.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski @claude
Issue apache#13265: let a settings server declare the repository orig…
98b3056
…ins its credentials may be used with

Server credentials are scoped to the origin (scheme, host and port) of the
repositories and mirrors declared with the same server id. Repositories
declared inside a settings profile only reach that set when the profile id is
listed in <activeProfiles>; a profile activated through <activation> or -P
contributes no origin, so its credentials are warned about under the default
origin scope and refused under strict, with nothing the operator can do about
it. The session is built before any project exists, so profile activation
cannot be evaluated there.

A <server> can now declare those origins explicitly:

  <server>
    <id>internal</id>
    <username>u</username>
    <password>p</password>
    <repositoryOrigins>
      <repositoryOrigin>https://repo.example.org>
      <repositoryOrigin>https://mirror.example.org:8443>
    </repositoryOrigins>
  </server>

The declared origins are added to the ones Maven derives on its own; nothing
is replaced. Values are bare origins, not repository URLs, and are validated:
a value no origin can be derived from is an error, while a full repository URL
is accepted with a warning naming the origin actually used. Values with a
property placeholder are skipped, as validation runs before interpolation.

The warnings of the origin binding now name <repositoryOrigins> as the way to
declare a missing origin.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@slawekjaranowski slawekjaranowski added the bug Something isn't working label Sep 26, 2026
@slawekjaranowski slawekjaranowski added this to the 3.10.0 milestone Sep 26, 2026
@slawekjaranowski
slawekjaranowski requested review from cstamas, gnodet and slachiewicz September 26, 2026 19:12
@slawekjaranowski slawekjaranowski linked an issue Sep 26, 2026 that may be closed by this pull request
Sort out credentials scope handling #13265
Closed
cstamas
cstamas approved these changes Sep 26, 2026
View reviewed changes
gnodet-bot
gnodet-bot approved these changes Sep 26, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Solid backport of #13268 to maven-3.10.x. The <repositoryOrigins> extension to <server> is clean and well-integrated:

  • Union semantics are correct: addOrigin in the server loop feeds into the existing declaredRepositoryOrigins map alongside mirror/repository origins, no replacement.
  • Malformed origins are safely ignored: originOf() returns null for unparseable URIs → addOrigin silently skips them. The validator catches these upfront at settings validation time with clear error messages.
  • Validation is thorough: covers empty values, missing scheme/host, user info leak, path/query/fragment warnings, and placeholder bypass (pre-interpolation). The .mdo version 1.3.0+ is consistent with aliases on this branch.
  • Warning messages are now actionable: they name <repositoryOrigins> as the fix and include the actual origin value via originHint().
  • Test coverage is comprehensive: origin-only server, strict scope, union with mirrors, malformed origin, and a full validator test suite.

No issues found.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski
slawekjaranowski merged commit ae59501 into apache:maven-3.10.x Sep 27, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned slawekjaranowski Sep 27, 2026
@cuioss-oliver cuioss-oliver mentioned this pull request Oct 3, 2026
fix: restore id-only credential matching for Maven 3.10.0 deploys cuioss/cuioss-parent-pom#1496
Closed
@YunaBraska YunaBraska mentioned this pull request Oct 5, 2026
feat: support Maven server credential origins actions/setup-java#1282
Merged
@slawekjaranowski slawekjaranowski mentioned this pull request Oct 15, 2026
Maven 3.10.0 - new warnings after upgrade from 3.9.16 #13468
Closed
@generalmimon generalmimon mentioned this pull request Oct 15, 2026
Use a dedicated Maven server id for Central Portal publishing kaitai-io/kaitai_struct_java_runtime#68
Merged
generalmimon added a commit to kaitai-io/kaitai_struct_java_runtime that referenced this pull request Oct 16, 2026
@generalmimon @claude
Use a dedicated Maven server id for Central Portal publishing (#68)
7615a56
GitHub Actions' hosted Ubuntu 24.04 runners
[now ship Maven 3.10](https://github.com/actions/runner-images/blob/7e7dc1bcc0ef464e5e315a2b4c33609590c6cffe/images/ubuntu/Ubuntu2404-Readme.md#project-management),
which [offers the credentials of a `<server>` in `settings.xml` only to
the repository origins associated with its id](https://maven.apache.org/docs/3.10.0/release-notes.html#Repository_credentials_are_scoped)
(an origin is a scheme, host and port). The setup-java action
generates this `settings.xml` from its `server-id` input.

The id `central` is also the id of Maven's built-in Central repository
(https://repo.maven.apache.org, where dependencies are downloaded from),
so Maven did not send our Central Portal user token (the
`CENTRAL_SONATYPE_*` secrets) to the Sonatype Central Portal
(https://central.sonatype.com), where we publish, and the snapshot
deploy in CI failed:

```
[WARNING] Not using credentials of server 'central' for repository https://central.sonatype.com/repository/maven-snapshots/: the origins declared for this id are [https://repo.maven.apache.org]. Add 'https://central.sonatype.com' to <repositoryOrigins> of that server in settings if these credentials belong there, or set maven.repository.credentialScope=id to restore legacy id-only credential matching.
[ERROR] Failed to execute goal org.sonatype.central:central-publishing-maven-plugin:0.8.0:publish (injected-central-publishing) on project kaitai-struct-runtime: Failed to deploy artifacts: Could not transfer artifact io.kaitai:kaitai-struct-runtime:jar:0.12-20261015.145648-9 from/to central (https://central.sonatype.com/repository/maven-snapshots/): HTTP Status: 401 -> [Help 1]
```

actions/setup-java#1284 describes the same
failure.

Unlike `central`, the new id `sonatype-central` is not the id of any
repository, so Maven ties no origin to it and uses its credentials for
the Central Portal.
[According to Maven's source](https://github.com/apache/maven/blob/c43a36b8d67be7e0805a411bc0898af1a51f5472/maven-core/src/main/java/org/apache/maven/internal/aether/OriginBoundAuthenticationSelector.java#L159-L169),
Maven should then log a different, non-blocking warning instead of the
one above: "Using credentials of server 'sonatype-central' ... although
no repository or mirror with this id is declared ... and the server
declares no `<repositoryOrigins>`".

Two alternatives were rejected:

- Adding https://central.sonatype.com to the `<repositoryOrigins>` of
  the `central` server: [declared origins are added to the discovered
  ones](apache/maven#13275),
  so Maven would still offer the token to repo.maven.apache.org (which
  never needs it), as Maven 3.9 did by matching credentials by id
  alone.
- Restoring the id-only matching with
  `-Dmaven.repository.credentialScope=id`: it would turn off the new
  origin scoping entirely.

The new warning can be silenced by declaring the origin as
`sonatype-central:https://central.sonatype.com` in the
`mvn-server-repository-origins` input of
[setup-java v6.1.0](https://github.com/actions/setup-java/releases/tag/v6.1.0);
this repository still uses setup-java v5.6.0, which lacks that input.

Release deploys will also need central-publishing-maven-plugin 0.12.0
or newer, the first version that
[supports Maven 3.10](https://github.com/sonatype-nexus-community/central-publishing-maven-plugin/blob/15c4bb23cb74f6f65357037278712c9c4620ab25/README.md#compatibility).
Older versions leave the extra files that Maven 3.10 writes into the
staging directory (`maven-metadata-local.xml`, `_remote.repositories`)
in the release bundle, [which Central rejects](https://central.sonatype.org/publish/publish-portal-maven/#0120-13-oct-2026)
(sonatype-nexus-community/central-publishing-maven-plugin#1).
This repository still uses 0.8.0.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Stephan202 added a commit to PicnicSupermarket/error-prone-support that referenced this pull request Oct 16, 2026
@Stephan202
Declare origins of Maven server credentials
370857d
Maven 3.10 binds server credentials to the origin of the repositories
that are declared using the same ID. This breaks two cases:
- The `central` credentials are used to deploy snapshots to
  `central.sonatype.com`, but are bound to `repo.maven.apache.org`. The
  credentials would thus no longer be sent when deploying.
- The `error-prone-fork` repository is declared in a profile that is
  activated using `-P`, so its origin is unknown when Maven starts.

Declare the origins explicitly to silence the associated warnings and to
keep the deployment working.

See:
- apache/maven#13275
@slawekjaranowski slawekjaranowski mentioned this pull request Oct 20, 2026
Document server repositoryOrigins in settings.xml apache/maven-site#1731
Merged
ibauersachs added a commit to dnsjava/dnsjava that referenced this pull request Oct 20, 2026
@ibauersachs
Fix publishing to Cental
29ccdd0
See apache/maven#13275
slachiewicz
slachiewicz approved these changes Nov 5, 2026
View reviewed changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cstamas cstamas cstamas approved these changes
@slachiewicz slachiewicz slachiewicz approved these changes
@gnodet gnodet Awaiting requested review from gnodet
+1 more reviewer
@gnodet-bot gnodet-bot gnodet-bot approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slawekjaranowski slawekjaranowski

Labels

bug Something isn't working

Projects

None yet

Milestone

3.10.0

Development

Successfully merging this pull request may close these issues.

Sort out credentials scope handling

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@slawekjaranowski @cstamas @slachiewicz @gnodet-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.