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

Bmoric/add fetch source schema in oauth #19392

Merged
merged 16 commits into from
Nov 16, 2022

Conversation

benmoriceau
Copy link
Contributor

What

Address https://github.com/airbytehq/oncall/issues/999. If in the oAuth config alreay exist in the DB, and is not updated, we are using it.

@octavia-squidington-iv octavia-squidington-iv added area/api Related to the api area/documentation Improvements or additions to documentation area/platform issues related to the platform area/server labels Nov 14, 2022
@octavia-squidington-iv octavia-squidington-iv removed area/api Related to the api area/documentation Improvements or additions to documentation labels Nov 14, 2022
@benmoriceau benmoriceau temporarily deployed to more-secrets November 14, 2022 19:51 Inactive
@benmoriceau benmoriceau marked this pull request as ready for review November 14, 2022 22:29
@benmoriceau
Copy link
Contributor Author

Trying to test it on my local at the moment.

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Had a few comments. Most important is the last one, where I ask about if we are using the right OAuth field in the connector spec

this.configRepository = configRepository;
this.oAuthImplementationFactory = new OAuthImplementationFactory(configRepository, httpClient);
this.trackingClient = trackingClient;
this.secretsRepositoryReader = secretsRepositoryReader;
}

public OAuthConsentRead getSourceOAuthConsent(final SourceOauthConsentRequest sourceDefinitionIdRequestBody)
Copy link
Contributor

Choose a reason for hiding this comment

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

This wasn't introduced by this PR, but this parameter should probably be named something like sourceOauthConsentRequestBody instead of sourceDefinitionIdRequestBody. Same for the destination method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Jsons.deserializeToStringMap(oAuthInputConfigurationFromInput)
.forEach((k, v) -> {
if (AirbyteSecretConstants.SECRETS_MASK.equals(v)) {
result.put(k, oAuthInputConfigurationFromDB.get(k).textValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we guaranteed that oAuthInputConfigurationFromDB will always have an entry for each key here? If not, this could result in an NPE, so we should probably handle that case explicitly

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 don't know. I will add a check in case if it is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 82 to 83
List<String> fieldsToGet =
buildJsonPathFromOAuthFlowInitParameters(spec.getAuthSpecification().getOauth2Specification().getOauthFlowInitParameters());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we pulling these fields from the spec.getAuthSpecification()? Isn't that the old/legacy way of configuring OAuth?

The if-statement above which does OAuthConfigSupplier.hasOAuthConfigSpecification(spec) is checking if advancedAuth is set on the spec, which is the new way of configuring OAuth. So it seems like we shouldn't be accessing the legacy auth config fields here right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, Unfortunatelly spec.getAdvancedAuth().getOauthConfigSpecification().getOauthUserInputFromConnectorConfigSpecification() is a Json object. I will have to parse it based on the description...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@benmoriceau benmoriceau temporarily deployed to more-secrets November 14, 2022 22:47 Inactive
@benmoriceau
Copy link
Contributor Author

moving back to draft in order to address comments

@benmoriceau benmoriceau temporarily deployed to more-secrets November 14, 2022 23:47 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 14, 2022 23:58 Inactive
Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

One more small comment, otherwise this looks fine to me

@@ -195,6 +237,19 @@ public void setDestinationInstancewideOauthParams(final SetInstancewideDestinati
configRepository.writeDestinationOAuthParam(param);
}

private JsonNode getOAuthInputConfigurationForConsent(final ConnectorSpecification spec,
final JsonNode hydratedSourceConnectionConfiguration,
final JsonNode destinationDefinitionIdRequestBody) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rename this last parameter to oAuthInputConfiguration, since this current parameter name is not really quite right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 16:55 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 16:55 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 18:36 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 18:36 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 19:38 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 19:40 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 22:28 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 15, 2022 23:16 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 16, 2022 16:16 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 16, 2022 16:17 Inactive
@benmoriceau benmoriceau temporarily deployed to more-secrets November 16, 2022 21:41 Inactive
@benmoriceau benmoriceau merged commit a968078 into master Nov 16, 2022
@benmoriceau benmoriceau deleted the bmoric/add-fetch-source-schema-in-oauth branch November 16, 2022 22:30
benmoriceau added a commit that referenced this pull request Nov 16, 2022
benmoriceau added a commit that referenced this pull request Nov 16, 2022
benmoriceau added a commit that referenced this pull request Nov 16, 2022
benmoriceau added a commit that referenced this pull request Nov 17, 2022
* Revert "Revert "Bmoric/add fetch source schema in oauth (#19392)" (#19512)"

This reverts commit f08b84f.

* Fix complete OAuth

* Use var
akashkulk pushed a commit that referenced this pull request Dec 2, 2022
* Update inputs

* PR comments and autogen files

* Fix oAuth retry

* Handle null

* Add missing ;

* PR comments

* use advanced oAuth

* PR comments

* More PR comments

* Format

* Avoid conflict in json extract

* Format
akashkulk pushed a commit that referenced this pull request Dec 2, 2022
akashkulk pushed a commit that referenced this pull request Dec 2, 2022
* Revert "Revert "Bmoric/add fetch source schema in oauth (#19392)" (#19512)"

This reverts commit f08b84f.

* Fix complete OAuth

* Use var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform area/server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants