Skip to content
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

Aesthetic clean-up / format OAuth code #7782

Merged
merged 9 commits into from
Nov 9, 2021

Conversation

ChristopheDuong
Copy link
Contributor

@ChristopheDuong ChristopheDuong commented Nov 9, 2021

What

Cleaning up oauth classes formatting code and renaming the base classes before changing APIs

How

The major change in this PR is that extractRefreshToken() is being refactored into extractOAuthOutput()
which is now always returning a flat map (non-nested) of values.

Then a second separate method formatOAuthOutput() is called to handle nesting of OAuth results under "credentials" (or some other node names) if necessary.
This method will be refactored in the future to follow some "AuthSpecification" fields in the spec.json instead of being hard-coded in the Flow implementation code.

The renaming of base classes is;

  • BaseOAuthConfig -> BaseOAuthFlow (inherited by BaseOAuth2Flow and TrelloOAuthFlow which is following OAuth 1.0, not OAuth 2.0)
  • BaseOAuthFlow -> BaseOAuth2Flow (inherited by all OAuthFlow implementations that follows OAuth 2.0)

@github-actions github-actions bot added area/connectors Connector related issues area/platform issues related to the platform area/server labels Nov 9, 2021
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 12:04 Inactive
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 12:16 Inactive
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 12:20 Inactive
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 12:28 Inactive
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 12:39 Inactive
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 12:46 Inactive
Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

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

All lgtm, just wanted to clarify my one comment below.

public BaseOAuthFlow(final ConfigRepository configRepository, HttpClient httpClient) {
this(configRepository, httpClient, BaseOAuthFlow::generateRandomState);
}
public abstract class BaseOAuthFlow implements OAuthFlowImplementation {
Copy link
Contributor

Choose a reason for hiding this comment

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

This renaming of these base classes implies abstraction for both OAuth[1] and OAuth2, because we have BaseOAuthFlow and then BaseOAuth2Flow that extends it.

Is it the intention (and therefore possible) that BaseOAuthFlow can be used for OAuth[1] flows? If not, then what is the purpose of distinction?

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, Trello OAuth is the only OAuth 1 for the moment

I am guessing if we have another oauth 1 flow, we'll be able to introduce a BaseOAuth1Flow at that moment to factor whatever common code shared between trello and that new one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, yeah agreed with that approach.

@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 13:27 Inactive
@ChristopheDuong ChristopheDuong temporarily deployed to more-secrets November 9, 2021 13:37 Inactive
@ChristopheDuong ChristopheDuong merged commit 21d6dd9 into master Nov 9, 2021
@ChristopheDuong ChristopheDuong deleted the chris/oauth-format-code branch November 9, 2021 14:21
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/platform issues related to the platform area/server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants