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

🎉 Source Snowflake: support oauth #10953

Merged
merged 15 commits into from
Apr 27, 2022

Conversation

yurii-bidiuk
Copy link
Contributor

@yurii-bidiuk yurii-bidiuk commented Mar 8, 2022

What

Fixes #10002
Implemented OAuth flow to Snowflake source.

Add option to select authorization method:
157645036-e97ec108-cfc0-46bc-b3f2-1935cb7f3d05

Authorization method "Username and password":

photo1648158089

Authorization method "OAuth2.0":

photo1648158089 (1)

How

  1. SourceSnowflakeOAuthFlow.class. Add OAuth flow to make authentication and get access and refresh tokens.
  2. spec.json. Change structure of specification. Added OAuth params. Split authentication methods to provide backward compatibility with username and password authentication.
  3. SourceSnowflake.class. Updated reading configuration due to the new structure of spec.json. Owerrided createDatabase() to use HikariDataSource which has ability to refresh access token for connection pool in execution time.
  4. SnowflakeDataSourceUtils.class. Utility class that has methods to HikariDataSource and refresh token every 7 minutes (access token expires in 10 mins).

Recommended reading order

  1. spec.json
  2. SourceSnowflakeOAuthFlow.class
  3. SourceSnowflake.class
  4. SnowflakeDataSourceUtils.class

🚨 User Impact 🚨

Added new authorization method. The existing auth method (username and password) moved to the bottom of the setting window. User is able to select which authorization method to use.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@github-actions github-actions bot added the area/connectors Connector related issues label Mar 8, 2022
@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/10002-src-snowflake-support-oauth branch 3 times, most recently from 1efdefc to 0bf86fe Compare March 8, 2022 12:06
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 8, 2022 22:31 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 8, 2022 22:31 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 9, 2022 22:39 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 9, 2022 22:39 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 9, 2022 22:45 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 9, 2022 22:45 Inactive
@yurii-bidiuk yurii-bidiuk changed the title [WIP]:🎉 Source Snowflake: support oauth 🎉 Source Snowflake: support oauth Mar 10, 2022
@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/10002-src-snowflake-support-oauth branch from a3bd575 to 5fdadb2 Compare March 21, 2022 16:40
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 21, 2022 16:43 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 21, 2022 16:43 Inactive
new IntegrationRunner(source).run(args);
isSourceAlive = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

this code doesn't look good, can isSourceAlive and tokenLoader logic be moved in a SnowflakeAccessTokenLoader or to a separate component?

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

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Mar 24, 2022
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 24, 2022 21:22 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 24, 2022 21:22 Inactive
@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/10002-src-snowflake-support-oauth branch from 105fcda to 335cdb3 Compare March 25, 2022 12:21
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 25, 2022 12:23 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets March 25, 2022 12:24 Inactive
if (config.has("jdbc_url_params")) {
jdbcUrl.append(config.get("jdbc_url_params").asText());
}
hikariConfig.setJdbcUrl(jdbcUrl.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move the logic of the URL building into a separate method? also, it would be great to cover it with some unit tests

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

properties.put("authenticator", "oauth");
properties.put("token", accessToken);
properties.put("account", config.get("host").asText());
hikariConfig.setDataSourceProperties(properties);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move properties populating block into a separate method to make it more readable?

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

@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/10002-src-snowflake-support-oauth branch from 5d58623 to d84c0cb Compare April 27, 2022 12:25
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 12:28 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 12:28 Inactive
@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented Apr 27, 2022

/test connector=connectors/source-snowflake

🕑 connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233127088
❌ connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233127088
🐛 https://gradle.com/s/sapiavkbi32km

@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented Apr 27, 2022

/test connector=connectors/source-snowflake

🕑 connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233217034
❌ connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233217034
🐛 https://gradle.com/s/memayqtjo3xc4

@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 13:03 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 13:03 Inactive
@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/10002-src-snowflake-support-oauth branch from 01268e0 to ff588a2 Compare April 27, 2022 13:59
@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented Apr 27, 2022

/test connector=connectors/source-snowflake

🕑 connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233546282
❌ connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233546282
🐛 https://gradle.com/s/b32yp5oc7xuc2

@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 14:01 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 14:01 Inactive
@yurii-bidiuk yurii-bidiuk force-pushed the bidiuk/10002-src-snowflake-support-oauth branch from ff588a2 to 36af69e Compare April 27, 2022 14:17
@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented Apr 27, 2022

/test connector=connectors/source-snowflake

🕑 connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233662124
✅ connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233662124
No Python unittests run

@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 14:19 Inactive
@yurii-bidiuk yurii-bidiuk temporarily deployed to more-secrets April 27, 2022 14:20 Inactive
@yurii-bidiuk
Copy link
Contributor Author

yurii-bidiuk commented Apr 27, 2022

/publish connector=connectors/source-snowflake

🕑 connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233784310
🚀 Successfully published connectors/source-snowflake
🚀 Auto-bumped version for connectors/source-snowflake
✅ connectors/source-snowflake https://github.com/airbytehq/airbyte/actions/runs/2233784310

@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets April 27, 2022 14:55 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets April 27, 2022 14:56 Inactive
@yurii-bidiuk yurii-bidiuk merged commit 45a212c into master Apr 27, 2022
@yurii-bidiuk yurii-bidiuk deleted the bidiuk/10002-src-snowflake-support-oauth branch April 27, 2022 15:52
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets April 28, 2022 10:18 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets April 28, 2022 10:18 Inactive
suhomud pushed a commit that referenced this pull request May 23, 2022
* add oauth flow to source-snowflake

* Add unit test for oauth flow

* add docs to method

* format code

* change configs

* fixed remarks

* fixed comments

* fixed PR remark

* update with master

* format code

* fix PR remmakrs

* add test for backward compatibility

* bump version

* small fix for test

* auto-bump connector version

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
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/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Snowflake: support oauth
4 participants