use of io.prestosql.server.InternalAuthenticationManager in project hetu-core by openlookeng.
the class QueryEditorUIModule method provideOkHttpClient.
@Singleton
@Provides
public OkHttpClient provideOkHttpClient(HttpServerConfig serverConfig, InternalCommunicationConfig internalCommunicationConfig, InternalAuthenticationManager internalAuthenticationManager) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.socketFactory(new SocketChannelSocketFactory());
setupTimeouts(builder, 30, SECONDS);
setupCookieJar(builder);
if (serverConfig.isHttpsEnabled() && internalCommunicationConfig.isHttpsRequired()) {
setupSsl(builder, Optional.of(serverConfig.getKeystorePath()), Optional.of(serverConfig.getKeystorePassword()), Optional.of(serverConfig.getKeystorePath()), Optional.of(serverConfig.getKeystorePassword()));
// Setup the authorization for UI queries
Interceptor authInterceptor = chain -> chain.proceed(internalAuthenticationManager.getJwtGenerator().map(Supplier::get).map(jwt -> chain.request().newBuilder().header(InternalAuthenticationManager.PRESTO_INTERNAL_BEARER, jwt).build()).orElse(chain.request()));
builder.addInterceptor(authInterceptor);
internalAuthenticationManager.getJwtGenerator().map(Supplier::get).orElse(null);
}
return builder.build();
}
Aggregations