tabular-io / iceberg-rest-image

Simple project to expose a catalog over REST using a Java catalog backend
Apache License 2.0
109 stars 45 forks source link

How to run REST Catalog Server with OAuth2 Authentication? #27

Open cloudcheflabs opened 1 year ago

cloudcheflabs commented 1 year ago

I want to add iceberg REST catalog with the value of OAUTH2 for the option of iceberg.rest-catalog.security to my trino cluster, for which REST catalog server needs to be run with support of OAuth2 authentication. I have added some codes at the end of RESTCatalogServer like this.

            RESTCatalogAdapter adapter = new RESTCatalogAdapter(backendCatalog());
            RESTCatalogServlet servlet = new RESTCatalogServlet(adapter);
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
            context.setContextPath("/");
            ServletHolder servletHolder = new ServletHolder(servlet);
            servletHolder.setInitParameter("javax.ws.rs.Application", "ServiceListPublic");
            context.addServlet(servletHolder, "/*");
            context.setVirtualHosts(null);
            context.setGzipHandler(new GzipHandler());

            Server httpServer =
                    new Server(PropertyUtil.propertyAsInt(System.getenv(), "REST_PORT", 8181));
            httpServer.setHandler(context);

            httpServer.start();

           // ADDED CODES!!!!!!!
            SessionCatalog.SessionContext sessionContext =
                    new SessionCatalog.SessionContext(
                            UUID.randomUUID().toString(),
                            "user",
                            ImmutableMap.of("credential", "user:secret"),
                            ImmutableMap.of());

            RESTCatalog catalog = new RESTCatalog(sessionContext, (config) -> adapter);
            catalog.initialize(
                    "prod", ImmutableMap.of(CatalogProperties.URI, "ignored", "token", "bearer-token"));

But it seems, this is not OAuth2 enabled server.

Anybody knows how to add OAuth2 authentication to RESTCatalogServer?

zeddit commented 9 months ago

@cloudcheflabs If you have any idea about how to add OAuth2 authentication to REST catalog, could you please let me know. great thanks. I am looking for this.

This repo seems a demo-like project but not the one that Tabular claimed to has the feature of lazy snapshot loading, multi-table commits, and caching and something of authentication and making make authorization decisions.