Skip to content

feat(rest): add an option to ignore server OAuth2 endpoints - #1041

Merged
wgtmac merged 6 commits into
apache:mainfrom
lishuxu:feat/rest-client-only-properties
Oct 28, 2026
Merged

wgtmac merged 6 commits into
apache:mainfrom
lishuxu:feat/rest-client-only-properties

Conversation

@lishuxu

@lishuxu lishuxu commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Introduce rest.auth.oauth2.trust-server-uri (default: true) to control whether server configuration can select the OAuth2 token endpoint.

When set to false:

  • The client must explicitly configure an oauth2-server-uri starting with http:// or https://.
  • The client endpoint is preserved after merging server defaults and overrides, even when the server changes uri.

Also align OAuth2 endpoint path handling with Java and reuse the resolved endpoint for refresh and child sessions. Add focused tests for these behaviors.

The default config merge precedence remains unchanged.

shuxu.li and others added 2 commits October 19, 2026 14:43
…r-uri

Introduce rest.client-only-properties, an opt-in mechanism that lets
clients prevent server-provided defaults/overrides from affecting
specified configuration keys. Keys listed in this property are resolved
from client configuration only.

When oauth2-server-uri appears in the list:
- Server-provided values for it are ignored during config merge
- The endpoint is resolved to an absolute URL using the client's uri
  before merging, preventing indirect override via uri changes
- InitSession and CatalogSession now use consistent endpoints

This addresses the risk of OAuth2 credentials being sent to an
unintended endpoint when a REST catalog server overrides
oauth2-server-uri or uri. The protection is opt-in to maintain
backward compatibility and align with REST spec defaults.

Changes:
- Add RestCatalogProperties::kClientOnlyProperties
- Export auth::ResolveOAuth2ServerUri for reuse
- Add MergeServerConfig() and ParseClientOnlyProperties() in rest_util
- Replace MergeConfigs with MergeServerConfig in RestCatalog::Make
- Warn when oauth2-server-uri is neither explicit nor protected while
  using credential auth (following Java's warnIfOAuthServerUriNotSet)
- Add unit tests covering direct/indirect override scenarios

Default behavior unchanged: without setting rest.client-only-properties,
server overrides apply as before, consistent with Java and Rust clients.

Co-Authored-By: Claude <noreply@anthropic.com>
- Construct string_view from an iterator pair; MSVC string_view
  iterators are not pointers.
- Parenthesize std::min in StringUtils so the Windows min() macro pulled
  in through cpr does not expand there.
@wgtmac wgtmac changed the title feat(rest): add opt-in client-only-properties to protect oauth2-serve… feat(rest): add opt-in client-only-properties to protect oauth2-server-uri Oct 22, 2026
Comment thread src/iceberg/catalog/rest/rest_catalog.cc Outdated
Comment thread src/iceberg/catalog/rest/auth/auth_properties.h Outdated
shuxu.li and others added 3 commits October 23, 2026 15:08
- Warn about an unset oauth2-server-uri when a token is set as well as
  a credential, matching Java's OAuth2Manager.warnIfOAuthServerUriNotSet.
- Export ResolveOAuth2ServerUri from the public auth_properties.h header.
…-properties

# Conflicts:
#	src/iceberg/test/rest_catalog_unit_test.cc
@wgtmac wgtmac changed the title feat(rest): add opt-in client-only-properties to protect oauth2-server-uri feat(rest): add an option to ignore server OAuth2 endpoints Oct 28, 2026

@wgtmac wgtmac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As we discussed offline, my earlier guidance made this PR more complicated than necessary. I've pushed a simpler version that replaces the generic client-only property list with a dedicated option for the OAuth2 endpoint. Sorry for the confusion, and thanks for your patience! @lishuxu

@wgtmac
wgtmac merged commit 0471f8f into apache:main Oct 28, 2026
15 checks passed
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.

3 participants