Skip to content

Conversation

@denodo-research-labs
Copy link
Contributor

Description

Bearer authentication for Nessie catalog is not working

Motivation and Context

Fixes the problem with Bearer authentication for Nessie catalog

Impact

Is not possible to connect to Nessie catalog using Bearer authentication

Test Plan

A new TestIcebergSystemTablesNessieWithBearerAuth class has been added. It extends TestIcebergSystemTablesNessie and re-runs those tests using Bearer authentication. The other Nessie tests are not duplicated, as this class sufficiently validates the authentication mechanism.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==
 
Iceberg Connector Changes
* Fix Bearer authentication with Nessie catalog.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 3, 2025

Reviewer's Guide

This PR implements support for Bearer authentication with the Nessie catalog by extending the testing infrastructure to spin up a Keycloak server, propagating the authentication type through the catalog factory, and validating the workflow with a new integration test.

Sequence diagram for Bearer authentication workflow with Nessie catalog

sequenceDiagram
    participant Test as "TestIcebergSystemTablesNessieWithBearerAuth"
    participant Keycloak as "KeycloakContainer"
    participant Nessie as "NessieContainer"
    participant Catalog as "IcebergNessieCatalogFactory"
    Test->>Keycloak: Request access token
    Keycloak-->>Test: Return Bearer token
    Test->>Catalog: Pass Bearer token and authentication type
    Catalog->>Nessie: Connect using Bearer authentication
    Nessie-->>Catalog: Authentication success
    Catalog-->>Test: Connection established
Loading

Entity relationship diagram for Keycloak and Nessie containers

erDiagram
    KEYCLOAK {
        string admin_username
        string admin_password
        int port
        string server_url
    }
    NESSIE {
        int port
        string version_store_type
    }
    KEYCLOAK ||--o| NESSIE : "provides Bearer token for"
    NESSIE {
        string authentication_type
    }
Loading

Class diagram for new KeycloakContainer and related changes

classDiagram
    class KeycloakContainer {
        +DEFAULT_IMAGE : String
        +DEFAULT_HOST_NAME : String
        +DEFAULT_USER_NAME : String
        +DEFAULT_PASSWORD : String
        +PORT : int
        +SERVER_URL : String
        +getUrl() : String
        +getAccessToken() : String
        +start()
        +setupContainer()
    }
    class BaseTestContainer {
    }
    class KeycloakContainer.Builder {
        +build() : KeycloakContainer
    }
    KeycloakContainer --|> BaseTestContainer
    KeycloakContainer.Builder --|> BaseTestContainer.Builder
    KeycloakContainer.Builder --> KeycloakContainer

    class NessieContainer {
        +DEFAULT_ENV_VARS : ImmutableMap<String, String>
    }
    NessieContainer.Builder --> NessieContainer

    class IcebergNessieCatalogFactory {
        +getCatalogProperties(session)
    }
    IcebergNessieCatalogFactory o-- CatalogConfig : catalogConfig

    class TestIcebergSystemTablesNessieWithBearerAuth {
    }
    TestIcebergSystemTablesNessieWithBearerAuth --|> TestIcebergSystemTablesNessie
Loading

File-Level Changes

Change Details Files
Enhanced test infrastructure to support Keycloak-based bearer authentication
  • Add Keycloak client dependencies to presto-testing-docker POM
  • Introduce KeycloakContainer for managing Keycloak test server
  • Extract DEFAULT_ENV_VARS in NessieContainer for consistent environment setup
presto-testing-docker/pom.xml
presto-testing-docker/src/main/java/com/facebook/presto/testing/containers/NessieContainer.java
presto-testing-docker/src/main/java/com/facebook/presto/testing/containers/KeycloakContainer.java
Support specifying authentication type in Iceberg Nessie catalog
  • Propagate catalogConfig.getAuthenticationType() into Nessie catalog properties
presto-iceberg/src/main/java/com/facebook/presto/iceberg/nessie/IcebergNessieCatalogFactory.java
New integration tests validating Bearer authentication
  • Create TestIcebergSystemTablesNessieWithBearerAuth to extend existing Nessie tests with bearer setup
  • Configure Nessie and Keycloak containers in test init for OIDC bearer flow
presto-iceberg/src/test/java/com/facebook/presto/iceberg/nessie/TestIcebergSystemTablesNessieWithBearerAuth.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `presto-testing-docker/src/main/java/com/facebook/presto/testing/containers/KeycloakContainer.java:102` </location>
<code_context>
+            RealmRepresentation masterRep = master.toRepresentation();
+            // change access token lifespan from 1 minute (default) to 1 hour
+            // to keep the token alive in case testcase takes more than a minute to finish execution.
+            masterRep.setAccessTokenLifespan(3600);
+            master.update(masterRep);
+            return keycloak.tokenManager().grantToken().getToken();
</code_context>

<issue_to_address>
**issue (bug_risk):** Changing the access token lifespan on every token request may have unintended side effects.

Setting the access token lifespan within getAccessToken() can cause race conditions in concurrent tests. It's better to configure this during container setup or initialization.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

RealmRepresentation masterRep = master.toRepresentation();
// change access token lifespan from 1 minute (default) to 1 hour
// to keep the token alive in case testcase takes more than a minute to finish execution.
masterRep.setAccessTokenLifespan(3600);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Changing the access token lifespan on every token request may have unintended side effects.

Setting the access token lifespan within getAccessToken() can cause race conditions in concurrent tests. It's better to configure this during container setup or initialization.

@denodo-research-labs denodo-research-labs marked this pull request as draft November 3, 2025 09:23
@denodo-research-labs denodo-research-labs force-pushed the bearer_authentication_nessie_catalog branch 2 times, most recently from 1e8efab to 45f4a0b Compare November 3, 2025 11:04
@denodo-research-labs denodo-research-labs force-pushed the bearer_authentication_nessie_catalog branch from 45f4a0b to f5c6fe6 Compare November 3, 2025 19:10
@tdcmeehan tdcmeehan self-assigned this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants