Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Users To Customize HttpClient #2410

Closed
hpoettker opened this issue Apr 25, 2024 · 1 comment · Fixed by #2413
Closed

Allow Users To Customize HttpClient #2410

hpoettker opened this issue Apr 25, 2024 · 1 comment · Fixed by #2413
Milestone

Comments

@hpoettker
Copy link
Contributor

Problem description

I can use the config server with Bitbucket (v8.19.1) over http and authenticate with a token by exposing a bean like this:

@Bean
public TransportConfigCallback tokenAuthCallback() {
  var headers = Map.of("Authorization", "Bearer " + TOKEN);
  return transport -> {
    if (transport instanceof TransportHttp transportHttp) {
      transportHttp.setAdditionalHeaders(headers);
    }
  };
}

This works generally fine but produces a warning like the following in the config service on every http connection to the repository:

WARN o.a.h.c.protocol.ResponseProcessCookies : Invalid cookie header: "Set-Cookie: BITBUCKETSESSIONID=XXXX; Max-Age=1209600; Expires=Thu, 09 May 2024 13:45:48 GMT; Path=/; Secure; HttpOnly". Invalid 'expires' attribute: Thu, 09 May 2024 13:45:48 GMT

Root cause

The problem can be fixed by setting the cookie spec of the request config to STANDARD with code like this (e.g. in HttpClient4Support):

httpClientBuilder.setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD))

Feature request

Setting the cookie spec of the underlying HttpClient is not impossible but rather elaborate at the moment (e.g. by redefining the implementation of ConfigurableHttpConnectionFactory). It would be great if JGitEnvironmentProperties had a property cookieSpec that would allow to set the cookie spec as needed.

@ryanjbaxter
Copy link
Contributor

Rather than introducing a property to do this I think it would provide us more flexibility if we added a way to customize the HttpClient. PR #2413 should accomplish this.

@ryanjbaxter ryanjbaxter changed the title Configurability of the Cookie Spec of jgit's http client Allow Users To Customize HttpClient Apr 26, 2024
@ryanjbaxter ryanjbaxter added this to the 4.1.2 milestone Apr 26, 2024
ryanjbaxter added a commit that referenced this issue Apr 29, 2024
natedanner pushed a commit to natedanner/spring-cloud__spring-cloud-config that referenced this issue May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
2 participants