cstamas opened a new pull request, #14179:
URL: https://github.com/apache/maven/pull/14179

   Forward port of https://github.com/apache/maven/pull/14173 to maven-4.0.x.
   
   Maven Resolver 2.0.27 adds token header authentication 
(apache/maven-resolver#2372). This exposes it in `settings.xml`:
   
   ```xml
   <!-- Authorization: Bearer <token>; username and password are ignored -->
   <server>
     <id>internal</id>
     <token>...</token>
   </server>
   
   <!-- sent as is in the named header, e.g. GitLab Private-Token, Job-Token or 
Deploy-Token -->
   <server>
     <id>gitlab</id>
     <token>...</token>
     <tokenHeader>Private-Token</tokenHeader>
   </server>
   ```
   
   Same as in #14173: settings model **1.4.0** fields `token` and 
`tokenHeader`, mapped to `AuthenticationBuilder.addBearerToken` / 
`addTokenHeader` in the session factory; `token` and `tokenHeader` on the 
`maven-artifact` `Authentication` for the older plugin path 
(`MavenRepositorySystem`, `LegacyRepositorySystem`, `RepositoryUtils`, no 
`Bearer Bearer …`); the same token checks in the deprecated compat 
`DefaultSettingsValidator`; Wagon ignores the token.
   
   Where Maven 4 differs:
   - **Model:** the fields live in `api/maven-api-settings`. The v3 model and 
the IO model version (`forcedIOModelVersion`) move from 1.3.0 to 1.4.0, and the 
v3-only code segments are widened from `1.0.0/1.3.0` to `1.0.0/1.4.0`, as was 
done at the last bump; without that the v3 `Proxy` loses `isActive()` and 
`getPort()`.
   - **Decryption:** `DefaultSettingsBuilder` already decrypts every settings 
value, so the token is decrypted without changes; `transformServer_Token` only 
adds the server to the error message. The compat `DefaultSettingsDecrypter` 
decrypts it too, with the legacy encryption warning. The 3.10.x "left 
encrypted" warning in the session factory has no counterpart here and is not 
ported.
   - **Project settings:** `token` and `tokenHeader` are dropped from project 
settings and warned about, like the other credentials, so a project cannot 
supply them.
   - **Validation:** the Maven 4 `DefaultSettingsValidator` runs after 
interpolation and decryption, so it does not skip `${…}` values; an unresolved 
placeholder in `tokenHeader` is reported as an invalid header name.
   - **Also carried by:** `LegacyRepositorySystemSessionExtender` and the 
standalone `ApiRunner`.
   
   **Depends on:** apache/maven-resolver#2372. `resolverVersion` is set to 
`2.0.27-SNAPSHOT`, so CI cannot build this until the resolver change is 
deployed. Switch to 2.0.27 once it is released.
   
   Release note: `settings-1.4.0.xsd` must be published to 
maven.apache.org/xsd. Site documentation: apache/maven-site#1853.
   
   Tests: new cases in both `DefaultSettingsValidatorTest`s, both settings 
decrypter/builder tests (including a project settings token test), 
`DefaultRepositorySystemSessionFactoryTest` (bearer and `Private-Token` round 
trip) and `LegacyRepositorySystemTest`. The full Maven 4 build (without ITs) 
passes locally against the resolver PR snapshot.
   
   - [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to