gnodet-bot commented on code in PR #14205:
URL: https://github.com/apache/maven/pull/14205#discussion_r4750864228
##########
impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -312,9 +312,19 @@ public SessionBuilder
newRepositorySessionBuilder(MavenExecutionRequest request)
if (properties != null && properties.length > 0) {
headers = new HashMap<>();
for (PlexusConfiguration property : properties) {
- headers.put(
- property.getChild("name").getValue(),
- property.getChild("value").getValue());
+ String name = property.getChild("name").getValue();
+ String value =
property.getChild("value").getValue();
+ headers.put(name, value);
+ // Wire token headers into Authentication so the
resolver enforces
+ // origin-scoping, preemptive sending, and RFC
9110 validation.
+ // Values were already decrypted by
DefaultSettingsBuilder.
+ if (name != null && value != null &&
HttpTransporterUtils.isValidTokenHeaderName(name)) {
+ if ("Authorization".equalsIgnoreCase(name) &&
value.startsWith("Bearer ")) {
+
authBuilder.addBearerToken(value.substring("Bearer ".length()));
Review Comment:
⚠️ **Empty bearer token not guarded**: if the configured value is exactly
`"Bearer "` (prefix with no token), `substring` returns `""` and
`addBearerToken("")` sends `Authorization: Bearer ` — a blank bearer header
that will produce a 401 at the repository.
```suggestion
String token = value.substring("Bearer
".length());
if (!token.isEmpty()) {
authBuilder.addBearerToken(token);
}
```
--
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]