use of io.confluent.ksql.api.auth.KsqlAuthorizationProviderHandler in project ksql by confluentinc.
the class AuthHandlers method setupAuthHandlers.
static void setupAuthHandlers(final Server server, final Router router, final boolean isInternalListener) {
final Optional<AuthHandler> jaasAuthHandler = getJaasAuthHandler(server);
final KsqlSecurityExtension securityExtension = server.getSecurityExtension();
final Optional<AuthenticationPlugin> authenticationPlugin = server.getAuthenticationPlugin();
final Optional<Handler<RoutingContext>> pluginHandler = authenticationPlugin.map(plugin -> new AuthenticationPluginHandler(server, plugin));
final Optional<SystemAuthenticationHandler> systemAuthenticationHandler = getSystemAuthenticationHandler(server, isInternalListener);
systemAuthenticationHandler.ifPresent(handler -> router.route().handler(handler));
if (jaasAuthHandler.isPresent() || authenticationPlugin.isPresent()) {
router.route().handler(AuthHandlers::pauseHandler);
router.route().handler(rc -> wrappedAuthHandler(rc, jaasAuthHandler, pluginHandler));
// For authorization use auth provider configured via security extension (if any)
securityExtension.getAuthorizationProvider().ifPresent(ksqlAuthorizationProvider -> router.route().handler(new KsqlAuthorizationProviderHandler(server.getWorkerExecutor(), ksqlAuthorizationProvider)));
router.route().handler(AuthHandlers::resumeHandler);
}
}
Aggregations