1raghavmahajan commented on code in PR #13741:
URL: https://github.com/apache/iceberg/pull/13741#discussion_r2266759205
##########
core/src/main/java/org/apache/iceberg/rest/auth/OAuth2Manager.java:
##########
@@ -273,33 +273,32 @@ protected OAuth2Util.AuthSession
newSessionFromTokenResponse(
}
private static void warnIfDeprecatedTokenEndpointUsed(Map<String, String>
properties) {
- if (usesDeprecatedTokenEndpoint(properties)) {
+ if (!properties.containsKey(OAuth2Properties.OAUTH2_SERVER_URI)) {
String credential = properties.get(OAuth2Properties.CREDENTIAL);
String initToken = properties.get(OAuth2Properties.TOKEN);
boolean hasCredential = credential != null && !credential.isEmpty();
boolean hasInitToken = initToken != null;
if (hasInitToken || hasCredential) {
LOG.warn(
"Iceberg REST client is missing the OAuth2 server URI
configuration and defaults to {}/{}. "
- + "This automatic fallback will be removed in a future Iceberg
release."
+ + "This automatic fallback will be removed in a future Iceberg
release. "
+ "It is recommended to configure the OAuth2 endpoint using
the '{}' property to be prepared. "
+ "This warning will disappear if the OAuth2 endpoint is
explicitly configured. "
+ "See https://github.com/apache/iceberg/issues/10537",
RESTUtil.stripTrailingSlash(properties.get(CatalogProperties.URI)),
ResourcePaths.tokens(),
OAuth2Properties.OAUTH2_SERVER_URI);
}
- }
- }
-
- private static boolean usesDeprecatedTokenEndpoint(Map<String, String>
properties) {
- if (properties.containsKey(OAuth2Properties.OAUTH2_SERVER_URI)) {
+ } else {
String oauth2ServerUri =
properties.get(OAuth2Properties.OAUTH2_SERVER_URI);
- boolean relativePath = !oauth2ServerUri.startsWith("http");
- boolean sameHost =
oauth2ServerUri.startsWith(properties.get(CatalogProperties.URI));
- return relativePath || sameHost;
+ if (!oauth2ServerUri.startsWith("http") &&
oauth2ServerUri.endsWith(ResourcePaths.tokens())) {
Review Comment:
We only want the warning for relative paths, not absolute ones. The idea
being if I've explicitly set the uri to be under the catalog URI then I should
be able to without getting warned. Going back
[to](https://github.com/apache/iceberg/pull/13741#discussion_r2254357385)
> but if we have to draw a line, the relative path seems less explicit and
more likely to indicate that they simply copied the default value to get rid of
the old warning.
I could simplify the check by just doing below but then we don't catch
prefixes like `/`; and I felt doing URI normalization might a bit overkill.
```suggestion
if (oauth2ServerUri.equals(ResourcePaths.tokens())) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]