Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Apr 17, 2024

Over time it became quite painful to add new parameters/functionality to AuthSession as can be seen with the recent changes from #8976 and from #9839.
Hence I'm proposing an AuthConfig class that carries all of the relevant configuration for an AuthSession.

@nastra nastra force-pushed the authconfig branch 4 times, most recently from e89bede to 70d3ef8 Compare April 17, 2024 07:26
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 @nastra for doing this. LGTM with a minor comment.

AuthConfig.builder()
.token(token)
.credential(credential())
.scope(SCOPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd consider SCOPE as one of the optional params. It is optional in both token exchange flow and client credential flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes SCOPE is optional, but the signer client uses a custom scope, which we need to provide here

Copy link
Contributor

Choose a reason for hiding this comment

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

We can get the scope from the optional OAuth parameters for signer. Also a rest catalog isn't necessary with signer. But I'm OK with either one.

AuthConfig.builder()
.token(token)
.credential(credential())
.scope(SCOPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can get the scope from the optional OAuth parameters for signer. Also a rest catalog isn't necessary with signer. But I'm OK with either one.

Copy link
Contributor

@dramaticlly dramaticlly left a comment

Choose a reason for hiding this comment

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

Thank you Eduard, looks promising but have some question hope you can answer on

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

Overall, this seems like a good improvement but I think the change removes a public constructor for AuthSession that we cannot remove; I think we'll need to address that before merging. Lmk if I'm missing something!

Comment on lines -471 to +465
public AuthSession(
Map<String, String> baseHeaders,
String token,
String tokenType,
String credential,
String scope,
String oauth2ServerUri,
Map<String, String> optionalOAuthParams) {
this.headers = RESTUtil.merge(baseHeaders, authHeaders(token));
this.token = token;
this.tokenType = tokenType;
this.expiresAtMillis = OAuth2Util.expiresAtMillis(token);
this.credential = credential;
this.scope = scope;
this.oauth2ServerUri = oauth2ServerUri;
this.optionalOAuthParams = optionalOAuthParams;
public AuthSession(Map<String, String> baseHeaders, AuthConfig config) {
this.headers = RESTUtil.merge(baseHeaders, authHeaders(config.token()));
this.config = config;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's public, unfortunately I don't think we can remove this constructor just yet, I think we'll have to deprecate like the other constructors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amogh-jahagirdar that constructor was introduced with 5f655a3 which didn't make it into any release and only exists on main

@amogh-jahagirdar amogh-jahagirdar merged commit 67e181e into apache:main Jun 3, 2024
@nastra nastra deleted the authconfig branch June 4, 2024 05:56
jasonf20 pushed a commit to jasonf20/iceberg that referenced this pull request Aug 4, 2024
sasankpagolu pushed a commit to sasankpagolu/iceberg that referenced this pull request Oct 27, 2024
zachdisc pushed a commit to zachdisc/iceberg that referenced this pull request Dec 23, 2024
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.

4 participants