Skip to content

Conversation

@sungwy
Copy link
Contributor

@sungwy sungwy commented Nov 2, 2023

Related: #8869

Introduce OAuth2Properties.TOKEN_URI = "token-uri" that can be used to override the default behavior that assumes that the Rest Catalog Server is an Auth Server, and that the token endpoint is provided on the Rest Catalog Server.

If this value is set, fetchToken and exchangeToken calls will use this endpoint instead to retrieve a valid access token.

HttpClient.execute call has been modified to submit requests against the provided string, if the value is a valid https uri. If not, it will fallback to the previous behavior and attempt to construct the baseUri against the config provided catalog uri.

All tests requiring checks against "v1/oauth/tokens" endpoint has been updated to be parameterized with a configurable endpoint argument, to make sure that all token calls are routed to the separate URI.

@sungwy sungwy requested a review from nastra November 16, 2023 18:06
@sungwy
Copy link
Contributor Author

sungwy commented Nov 16, 2023

Took your suggestions @nastra . I've added the supporting documentation to the OpenAPI spec in this PR to follow up on the discussion on the Slack thread

@sungwy sungwy requested a review from nastra November 20, 2023 17:16
@sungwy
Copy link
Contributor Author

sungwy commented Nov 20, 2023

Incorporated suggested changes @nastra . Thank you for the reviews!

@sungwy
Copy link
Contributor Author

sungwy commented Dec 1, 2023

Leaving a comment to keep the PR active - @nastra @danielcweeks

Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

Thanks @syun64 for working on this. LGTM overall. Adding minor comments.

this.oauth2ServerUri = oauth2ServerUri;
}

public AuthSession(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it is not used anywhere. Should we deprecate it? If that's so, can we add deprecation comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that too. I lack the context to make that decision, so I will leave this comment thread for others to opine

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't appear to be referenced anymore so you should add a deprecation warning and message (see deprecation docs)

Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

LGTM overall. Added minor comments. Thanks @syun64 for working on it.

this.oauth2ServerUri = oauth2ServerUri;
}

public AuthSession(
Copy link
Contributor

Choose a reason for hiding this comment

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

return properties().get(OAuth2Properties.CREDENTIAL);
}

/** Token endpoint URI to fetch token from if the Rest Catalog is not the authorization server. */
Copy link
Contributor

Choose a reason for hiding this comment

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

"Token endpoint URI" -> "OAuth Server URI" or just "Endpoint"?

@mrcnc
Copy link
Contributor

mrcnc commented Feb 15, 2024

LGTM - Thanks for adding this! I look forward to using it 🚀

@danielcweeks danielcweeks self-requested a review February 16, 2024 19:12
throw new RESTException("Unhandled error: %s", errorResponse);
}

private String buildPath(String path) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is looking a lot cleaner now. However, we've now reduced this to a single call in execute where we chain buildUri(buildPath(path). This can just be collapsed to a single method since they're both private and only called in one spot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the suggested change @danielcweeks . Thank you for the review!

Copy link
Contributor

@danielcweeks danielcweeks left a comment

Choose a reason for hiding this comment

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

LGTM, just waiting on checks

@danielcweeks danielcweeks merged commit 9dcf8db into apache:main Feb 17, 2024
@sungwy sungwy changed the title Support usage of Separate OIDC Authorization Server URI Core: Support usage of Separate Authorization Server URI in Rest Catalog Feb 17, 2024
bitsondatadev pushed a commit to bitsondatadev/iceberg that referenced this pull request Mar 3, 2024
* configurable token-uri

* more tests

* lint

* minor changes

* suppress style

* address feedback

* adopt review feedback

* update config name

* lint

* adopt review comments
devangjhabakh pushed a commit to cdouglas/iceberg that referenced this pull request Apr 22, 2024
* configurable token-uri

* more tests

* lint

* minor changes

* suppress style

* address feedback

* adopt review feedback

* update config name

* lint

* adopt review comments
@sungwy sungwy deleted the auth-uri branch July 27, 2024 21:14
zachdisc pushed a commit to zachdisc/iceberg that referenced this pull request Dec 23, 2024
* configurable token-uri

* more tests

* lint

* minor changes

* suppress style

* address feedback

* adopt review feedback

* update config name

* lint

* adopt review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants