-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Introduce AuthConfig #10161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Introduce AuthConfig #10161
Conversation
e89bede to
70d3ef8
Compare
flyrain
left a comment
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
dramaticlly
left a comment
There was a problem hiding this 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
amogh-jahagirdar
left a comment
There was a problem hiding this 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!
| 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Over time it became quite painful to add new parameters/functionality to
AuthSessionas can be seen with the recent changes from #8976 and from #9839.Hence I'm proposing an
AuthConfigclass that carries all of the relevant configuration for anAuthSession.