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 #13268 · apache/maven

Conversation

@slawekjaranowski

@slawekjaranowski slawekjaranowski commented Sep 24, 2026

Copy link
Copy Markdown
Member

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). 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.
  • The warnings emitted by the origin binding now name <repositoryOrigins> as the place to declare a missing origin, so the message is actionable.

Project settings

<repositoryOrigins> is dropped from project settings (.mvn/settings.xml) and warned about, exactly like credentials are. This is a security requirement: settings list fields merge by union, and a project-settings <server> with the same id survives as a separate entry of the servers list, which the session factory reads too. Without the scrub, a project could widen the set of hosts its user's credentials are sent to. DefaultSettingsParserTest#projectSettingsCannotWidenServerCredentialOrigins fails without it.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

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

All reactions
@slawekjaranowski
slawekjaranowski requested review from cstamas, gnodet and slachiewicz September 24, 2026 21:23
@slawekjaranowski slawekjaranowski added the bug Something isn't working label Sep 24, 2026
@slawekjaranowski slawekjaranowski linked an issue Sep 24, 2026 that may be closed by this pull request
Sort out credentials scope handling #13265
Closed
@slawekjaranowski slawekjaranowski self-assigned this Sep 24, 2026
gnodet-bot
gnodet-bot approved these changes Sep 25, 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 feature addition. The validation logic is thorough, the compat/impl validators are properly symmetric (with the correct intentional asymmetry on placeholder handling: compat skips ${...} since it validates pre-interpolation, impl flags it as an error post-interpolation). The project-settings scrub correctly prevents origin widening — the security test projectSettingsCannotWidenServerCredentialOrigins covers this end-to-end. addOrigin gracefully handles malformed URIs via the originOf null guard. Test coverage is comprehensive: valid origins, missing scheme, missing host, user info, empty, path warning, placeholders, project settings restriction, mirror+server union, malformed, and strict scope.

One note: this PR has no milestone set. Given it fixes #13265, it might warrant one (4.1.0?).

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 added this to the 4.1.0 milestone Sep 25, 2026
@slawekjaranowski

slawekjaranowski commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

One note: this PR has no milestone set. Given it fixes #13265, it might warrant one (4.1.0?).

this is for master - 4.1.0, after merge I will cherry-pick also to 4.0.x and 3.10.x

All reactions

Sorry, something went wrong.

Uh oh!

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

@cstamas

cstamas commented Sep 26, 2026

Copy link
Copy Markdown
Member

I'd wished for 3.10 PR, as unsure how easily is this exact change cherry-pick-able to 3.10 due differences between 4.1.x and 3.10.x... also, given this is very very last issue for 3.10, and I am keen to release it (maybe release both at once, Resolver 2.0.24 and 3.10?)...

All reactions

Sorry, something went wrong.

Uh oh!

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

@slawekjaranowski

slawekjaranowski commented Sep 26, 2026

Copy link
Copy Markdown
Member Author

I'd wished for 3.10 PR, as unsure how easily is this exact change cherry-pick-able to 3.10 due differences between 4.1.x and 3.10.x... also, given this is very very last issue for 3.10, and I am keen to release it (maybe release both at once, Resolver 2.0.24 and 3.10?)...

I will do it .... in 3.10.x we have a less files in different modules - but it is the same

All reactions

Sorry, something went wrong.

Uh oh!

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

@slawekjaranowski slawekjaranowski mentioned this pull request Sep 26, 2026
Issue #13265: let a settings server declare the repository origins its credentials may be used with #13275
Merged
@slawekjaranowski @claude
Issue apache#13265: let a settings server declare the repository orig…
17bc761
…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. The deprecated V3
validator skips values with a property placeholder, as it runs before
interpolation.

The element is dropped from project settings, like credentials are. This is a
security requirement rather than tidiness: settings list fields merge by union
and a project-settings <server> of the same id survives as a separate entry, so
without it a project could widen the origins its user's credentials are sent
to.

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 force-pushed the issue-13265-server-repository-origins branch from 024e0f0 to 17bc761 Compare September 26, 2026 19:22
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.

Re-reviewed after force-push (024e0f0 → 17bc761). The delta is cosmetic: section-divider comments (// --- Field validation --- and their Javadoc) were moved to sit after the new validateRepositoryOrigins method instead of in the middle of it — no logic changes. Milestone now set to 4.1.0 as discussed. Solid, no issues.

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
slachiewicz
slachiewicz approved these changes Sep 28, 2026
View reviewed changes
@slawekjaranowski
slawekjaranowski merged commit c23bdb1 into apache:master Oct 1, 2026
39 of 40 checks passed

Uh oh!

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

@slawekjaranowski
slawekjaranowski deleted the issue-13265-server-repository-origins branch October 1, 2026 20:44
@slawekjaranowski slawekjaranowski mentioned this pull request Oct 1, 2026
Issue #13265: let a settings server declare the repository origins its credentials may be used with #13314
Merged
This was referenced Oct 10, 2026
support the native <repositoryOrigins> server field (Maven 3.10+ credential scoping) s4u/maven-settings-action#464
Closed
origin-based credential scoping workaround killbill/gh-actions-shared#100
Merged
This was referenced Oct 19, 2026
Support repositoryOrigins in servers s4u/maven-settings-action#467
Merged
Activate profiles by activeProfiles instead of activeByDefault s4u/maven-settings-action#468
Merged
Document server repositoryOrigins in settings.xml apache/maven-site#1731
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slachiewicz slachiewicz slachiewicz approved these changes
@gnodet gnodet Awaiting requested review from gnodet
@cstamas cstamas Awaiting requested review from cstamas
+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

4.2.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.