use of io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor in project che-server by eclipse-che.
the class OpenShiftClientFactory method clientForConfig.
private OkHttpClient clientForConfig(Config config) {
OkHttpClient clientHttpClient = getHttpClient().newBuilder().authenticator(Authenticator.NONE).build();
OkHttpClient.Builder builder = clientHttpClient.newBuilder();
builder.interceptors().clear();
return builder.addInterceptor(new OpenShiftOAuthInterceptor(clientHttpClient, OpenShiftConfig.wrap(config))).addInterceptor(new ImpersonatorInterceptor(config)).build();
}
use of io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor in project che-server by eclipse-che.
the class KubernetesClientFactory method create.
/**
* Creates instance of {@link KubernetesClient} that uses an {@link OkHttpClient} instance derived
* from the shared {@code httpClient} instance in which interceptors are overridden to
* authenticate with the credentials (user/password or Oauth token) contained in the {@code
* config} parameter.
*/
protected BaseKubernetesClient<?> create(Config config) {
OkHttpClient clientHttpClient = httpClient.newBuilder().authenticator(Authenticator.NONE).build();
OkHttpClient.Builder builder = clientHttpClient.newBuilder();
builder.interceptors().clear();
builder.addInterceptor(buildKubernetesInterceptor(config)).addInterceptor(new ImpersonatorInterceptor(config));
initializeRequestTracing(builder);
clientHttpClient = builder.build();
return new UnclosableKubernetesClient(clientHttpClient, config);
}
use of io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor in project devspaces-images by redhat-developer.
the class KubernetesClientFactory method create.
/**
* Creates instance of {@link KubernetesClient} that uses an {@link OkHttpClient} instance derived
* from the shared {@code httpClient} instance in which interceptors are overridden to
* authenticate with the credentials (user/password or Oauth token) contained in the {@code
* config} parameter.
*/
protected BaseKubernetesClient<?> create(Config config) {
OkHttpClient clientHttpClient = httpClient.newBuilder().authenticator(Authenticator.NONE).build();
OkHttpClient.Builder builder = clientHttpClient.newBuilder();
builder.interceptors().clear();
builder.addInterceptor(buildKubernetesInterceptor(config)).addInterceptor(new ImpersonatorInterceptor(config));
initializeRequestTracing(builder);
clientHttpClient = builder.build();
return new UnclosableKubernetesClient(clientHttpClient, config);
}
use of io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor in project kubernetes-client by fabric8io.
the class HttpClientUtils method createApplicableInterceptors.
public static Map<String, io.fabric8.kubernetes.client.http.Interceptor> createApplicableInterceptors(Config config, HttpClient.Factory factory) {
Map<String, io.fabric8.kubernetes.client.http.Interceptor> interceptors = new LinkedHashMap<>();
// Header Interceptor
interceptors.put(HEADER_INTERCEPTOR, new Interceptor() {
@Override
public void before(BasicBuilder builder, HttpHeaders headers) {
if (Utils.isNotNullOrEmpty(config.getUsername()) && Utils.isNotNullOrEmpty(config.getPassword())) {
builder.header("Authorization", basicCredentials(config.getUsername(), config.getPassword()));
} else if (Utils.isNotNullOrEmpty(config.getOauthToken())) {
builder.header("Authorization", "Bearer " + config.getOauthToken());
}
if (config.getCustomHeaders() != null && !config.getCustomHeaders().isEmpty()) {
for (Map.Entry<String, String> entry : config.getCustomHeaders().entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
if (config.getUserAgent() != null && !config.getUserAgent().isEmpty()) {
builder.setHeader("User-Agent", config.getUserAgent());
}
}
});
// Impersonator Interceptor
interceptors.put(ImpersonatorInterceptor.NAME, new ImpersonatorInterceptor(config));
// Token Refresh Interceptor
interceptors.put(TokenRefreshInterceptor.NAME, new TokenRefreshInterceptor(config, factory));
// Backwards Compatibility Interceptor
String shouldDisableBackwardsCompatibilityInterceptor = Utils.getSystemPropertyOrEnvVar(KUBERNETES_BACKWARDS_COMPATIBILITY_INTERCEPTOR_DISABLE, "false");
if (!Boolean.parseBoolean(shouldDisableBackwardsCompatibilityInterceptor)) {
interceptors.put(BackwardsCompatibilityInterceptor.NAME, new BackwardsCompatibilityInterceptor());
}
return interceptors;
}
use of io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor in project devspaces-images by redhat-developer.
the class OpenShiftClientFactory method clientForConfig.
private OkHttpClient clientForConfig(Config config) {
OkHttpClient clientHttpClient = getHttpClient().newBuilder().authenticator(Authenticator.NONE).build();
OkHttpClient.Builder builder = clientHttpClient.newBuilder();
builder.interceptors().clear();
return builder.addInterceptor(new OpenShiftOAuthInterceptor(clientHttpClient, OpenShiftConfig.wrap(config))).addInterceptor(new ImpersonatorInterceptor(config)).build();
}
Aggregations