Skip to content

feat(rest): support OAuth token exchange sessions - #867

Open
lishuxu wants to merge 2 commits into
apache:mainfrom
lishuxu:feature/oauth-1
Open

feat(rest): support OAuth token exchange sessions#867
lishuxu wants to merge 2 commits into
apache:mainfrom
lishuxu:feature/oauth-1

Conversation

@lishuxu

@lishuxu lishuxu commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Add RFC 8693 token exchange support, including token type helpers, request form construction, OAuth endpoint normalization, and response handling.

Preserve OAuth metadata in auth sessions and create contextual and table-scoped child sessions from direct tokens, credentials, or typed tokens. Disable child refresh until session lifecycle management is available.

Add RFC 8693 token exchange support, including token type helpers,
request form construction, OAuth endpoint normalization, and response
handling.

Preserve OAuth metadata in auth sessions and create contextual and
table-scoped child sessions from direct tokens, credentials, or typed
tokens. Disable child refresh until session lifecycle management is
available.
if (token_it != credentials.end()) {
ICEBERG_ASSIGN_OR_RAISE(auto config,
ChildConfig(*parent_info, parent_info->credential));
return MakeSession(AccessTokenResponse(token_it->second), config,

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.

Child sessions are always created with keep_refreshed=false, so a token-exchange response with expires_in or JWT exp is never refreshed. A long-lived table/context session will keep sending an expired token. Can we either schedule child refresh or explicitly limit expiring child tokens here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This patch intentionally supports initial token exchange only.
Child-session caching and refresh are deferred to a follow-up change, because enabling refresh without cache/session ownership would create unmanaged refresh tasks.


Result<std::shared_ptr<AuthSession>> ContextualSession(
const SessionContext& context, std::shared_ptr<AuthSession> parent) override {
return MaybeCreateChildSession(context.credentials, /*allow_credential=*/true,

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.

This path creates a new child session for every contextual operation. Without a cache, repeated operations with the same context re-exchange or fetch a token each time, which can hit OAuth rate limits. Can we cache child sessions by context/credential before enabling this path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. This is part of the session lifecycle limitation.
This patch only supports initial child-session creation. Session caching and child-session refresh will be implemented in a follow-up PR.

    Add RFC 8693 token exchange support, including token type helpers,
    request form construction, OAuth endpoint normalization, and response
    handling.

    Preserve OAuth metadata in auth sessions and create contextual and
    table-scoped child sessions from direct tokens, credentials, or typed
    tokens. Disable child refresh until session lifecycle management is
    available.
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