Skip to content

Conversation

@jerqi
Copy link
Contributor

@jerqi jerqi commented Jan 5, 2026

What changes were proposed in this pull request?

Fix Flink connector oauth2 mode.

Why are the changes needed?

This is a follow up PR.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

By hand.

@jerqi jerqi self-assigned this Jan 5, 2026
@jerqi jerqi requested a review from Copilot January 5, 2026 07:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes OAuth2 authentication mode configuration in the Flink connector. The changes address issues where OAuth2 configuration keys were not properly handled when building the Gravitino client.

Key changes:

  • Adds a constant for the "oauth2" string to improve maintainability
  • Fixes OAuth2 client configuration by removing OAuth-specific keys before passing config to GravitinoAdminClient
  • Updates documentation example to show correct credential format

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
GravitinoCatalogStoreFactoryOptions.java Adds OAUTH2 constant to centralize the "oauth2" string value
GravitinoCatalogManager.java Refactors OAuth2 client building logic to remove OAuth config keys from client config map and use the new OAUTH2 constant
flink-authentication-with-gravitino.md Updates documentation to show correct OAuth2 credential format

String.format(
"OAuth2 authentication requires: %s, %s, %s, and %s",

// Remove OAuth config from client config map, Because
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The word 'Because' should not be capitalized mid-sentence. Change 'Because' to 'because'.

Suggested change
// Remove OAuth config from client config map, Because
// Remove OAuth config from client config map, because

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 249 to 250
// Remove OAuth config from client config map, Because
// GravitinoAdminClient.builder().withClientConfig() does not recognize these keys.
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The comment should explain why removing these keys is necessary. Consider clarifying that these OAuth2-specific keys would cause validation errors or unexpected behavior if passed to the GravitinoAdminClient builder.

Suggested change
// Remove OAuth config from client config map, Because
// GravitinoAdminClient.builder().withClientConfig() does not recognize these keys.
// Remove OAuth-specific config entries from the client config map. These keys are only
// used to construct the OAuth2 token provider and are not valid GravitinoAdminClient
// client configuration options; passing them to withClientConfig() could cause validation
// errors or other unexpected behavior.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 248 to 260

// Remove OAuth config from client config map, Because
// GravitinoAdminClient.builder().withClientConfig() does not recognize these keys.
Set<String> oauthConfigKeys =
Sets.newHashSet(
GravitinoCatalogStoreFactoryOptions.AUTH_TYPE,
GravitinoCatalogStoreFactoryOptions.OAUTH2_SERVER_URI,
GravitinoCatalogStoreFactoryOptions.OAUTH2_CREDENTIAL,
GravitinoCatalogStoreFactoryOptions.OAUTH2_TOKEN_PATH,
GravitinoCatalogStoreFactoryOptions.OAUTH2_SCOPE));
GravitinoCatalogStoreFactoryOptions.OAUTH2_SCOPE);
for (String key : oauthConfigKeys) {
config.remove(key);
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The new logic for removing OAuth config keys from the client config map lacks test coverage. Add a unit test to verify that these specific keys are properly removed from the config before it's passed to the GravitinoAdminClient builder.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's hard to add tests. I test it by hand.

@jerqi jerqi requested a review from FANNG1 January 7, 2026 06:28
@jerqi
Copy link
Contributor Author

jerqi commented Jan 7, 2026

@FANNG1 Could u take a look at this pull request?

@yuqi1129
Copy link
Contributor

yuqi1129 commented Jan 8, 2026

@jerqi
Does it need to cherry-pick to branch-1.1?

@jerqi
Copy link
Contributor Author

jerqi commented Jan 8, 2026

@jerqi Does it need to cherry-pick to branch-1.1?

No need. The branch 1.1 doesn't have the similar issue. I don't back port the pull request which bring this issue to branch-1.1.

// Only OAuth is explicitly configured; otherwise follow Flink security (Kerberos if enabled,
// simple auth otherwise).
if (AuthenticatorType.OAUTH.name().equalsIgnoreCase(authType)) {
if (GravitinoCatalogStoreFactoryOptions.OAUTH2.equalsIgnoreCase(authType)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for using a new constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OAUTH name is oauth. We need OAUTH2 here.
Spark use the constants in the catalog-common.
So I defined a new constant here.
I will refactor related code in the future. I can create an issue for this.

authType, GravitinoCatalogStoreFactoryOptions.AUTH_TYPE));
}

LOG.info("Flink security enabled: {}", UserGroupInformation.isSecurityEnabled());
Copy link
Contributor

Choose a reason for hiding this comment

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

How about simple by using one log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I just feel it will be a little long.

@FANNG1
Copy link
Contributor

FANNG1 commented Jan 8, 2026

LGTM, some minor comments

@jerqi jerqi merged commit 38c420d into apache:main Jan 8, 2026
23 checks passed
@jerqi jerqi deleted the fix_oauth2 branch January 8, 2026 08:52
@jerryshao
Copy link
Contributor

Shall we backport branch-1.1?

@jerqi
Copy link
Contributor Author

jerqi commented Jan 8, 2026

Shall we backport branch-1.1?
This is the issue #9564 follow up PR. Because #9564 didn't back port to branch 1.1. So branch 1.1 won't have the similar issue.

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.

4 participants