cstamas commented on code in PR #2372:
URL: https://github.com/apache/maven-resolver/pull/2372#discussion_r4728760941
##########
maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java:
##########
@@ -70,6 +70,16 @@ public final class AuthenticationContext implements
Closeable {
*/
public static final String PASSWORD = "password";
+ /**
+ * The key used to store the bearer token. The corresponding
authentication data should be of type {@code char[]}
+ * or {@link String}. HTTP transports (except Wagon) send it preemptively
as {@code Authorization: Bearer <token>}
+ * header, scoped to the repository origin, and when present, it takes
precedence over {@link #USERNAME} and
+ * {@link #PASSWORD}.
+ *
+ * @since 2.0.27
+ */
+ public static final String BEARER_TOKEN = "bearerToken";
Review Comment:
Fixed in 690c94d2: the key is now `"bearer.token"`, matching the dotted
convention of the other keys.
##########
maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk11/src/main/java/org/eclipse/aether/transport/jdk/JdkTransporter.java:
##########
@@ -237,6 +235,14 @@ static boolean isExpectContinueSupported(Runtime.Version
version) {
if (configuredHeaders != null) {
headers.putAll(configuredHeaders);
}
+ String bearerToken;
+ try (AuthenticationContext repoAuthContext =
AuthenticationContext.forRepository(session, repository)) {
+ bearerToken = repoAuthContext != null ?
repoAuthContext.get(AuthenticationContext.BEARER_TOKEN) : null;
+ }
Review Comment:
Fixed in 690c94d2: the JDK transporter now opens the repository
`AuthenticationContext` only once, in `createClient()`, like the other
transports. The constructor sets up the cross-origin excluded headers only for
origin-scoped headers; `createClient()` reads the bearer token, adds the
`Authorization: Bearer` header, and adds `Authorization` to the excluded set
itself. The redirect decisions (`Redirect.NEVER` and self-follow) read that set
after `createClient()` has filled it, so the token stays on the repository
origin even with origin-scoped headers disabled, as before.
--
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]