Skip to content

Commit

Permalink
🐛Source Auth0 - Fix low code migration bugs (#29804)
Browse files Browse the repository at this point in the history
Co-authored-by: marcosmarxm <[email protected]>
Co-authored-by: sajarin <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2023
1 parent e82178f commit db7a93e
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 40 deletions.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-auth0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_auth0 ./source_auth0
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.4.0
LABEL io.airbyte.version=0.4.1
LABEL io.airbyte.name=airbyte/source-auth0

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion airbyte-integrations/connectors/source-auth0/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ data:
enabled: true
cloud:
enabled: true
connectorBuildOptions:
baseImage: airbyte/airbyte-python-connectors-base:0.1.0
connectorSubtype: api
connectorType: source
definitionId: 6c504e48-14aa-4221-9a72-19cf5ff1ae78
dockerImageTag: 0.4.0
dockerImageTag: 0.4.1
dockerRepository: airbyte/source-auth0
githubIssueLabel: source-auth0
icon: auth0.svg
Expand Down
1 change: 0 additions & 1 deletion airbyte-integrations/connectors/source-auth0/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
TEST_REQUIREMENTS = [
"pytest~=6.2",
"pytest-mock~=3.6.1",
"connector-acceptance-test",
]

setup(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

from dataclasses import dataclass
from typing import Any, Mapping

from airbyte_cdk.sources.declarative.auth import DeclarativeOauth2Authenticator
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
from airbyte_cdk.sources.declarative.auth.token import BearerAuthenticator


@dataclass
class AuthenticatorAuth0(DeclarativeAuthenticator):
config: Mapping[str, Any]
bearer: BearerAuthenticator
oauth: DeclarativeOauth2Authenticator

def __new__(cls, bearer, oauth, config, *args, **kwargs):
auth_type = config.get("credentials", {}).get("auth_type")
if auth_type == "oauth2_access_token":
return bearer
elif auth_type == "oauth2_confidential_application":
return oauth
else:
raise Exception("Not possible configure Auth method")
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,46 @@ definitions:
type: DpathExtractor
field_path: []

oauth_authenticator:
type: OAuthAuthenticator
token_refresh_endpoint: "{{ config['base_url'] }}oauth/token"
client_id: "{{ config['credentials']['client_id'] }}"
client_secret: "{{ config['credentials']['client_secret'] }}"
refresh_token: ""

bearer_authenticator:
type: BearerAuthenticator
api_token: "{{ config['credentials']['access_token'] }}"

requester:
type: HttpRequester
url_base: "{{ config['base_url'] }}"
url_base: "{{ config['base_url'] }}/api/v2"
http_method: "GET"
authenticator:
type: BearerAuthenticator
api_token: "{{ config['credentials']['access_token'] }}"
class_name: source_auth0.components.AuthenticatorAuth0
bearer: "#/definitions/bearer_authenticator"
oauth: "#/definitions/oauth_authenticator"

paginator:
type: "DefaultPaginator"
page_size_option:
type: "RequestOption"
inject_into: "request_parameter"
field_name: "per_page"
pagination_strategy:
type: "PageIncrement"
page_size: 50
page_token_option:
type: "RequestOption"
inject_into: "request_parameter"
field_name: "page"

retriever:
type: SimpleRetriever
record_selector:
$ref: "#/definitions/selector"
paginator:
type: "DefaultPaginator"
page_size_option:
type: "RequestOption"
inject_into: "request_parameter"
field_name: "per_page"
pagination_strategy:
type: "PageIncrement"
page_size: 5
page_token_option:
type: "RequestOption"
inject_into: "request_parameter"
field_name: "page"
$ref: "#/definitions/paginator"
requester:
$ref: "#/definitions/requester"

Expand All @@ -48,23 +63,44 @@ definitions:
path: "clients"

users_stream:
$ref: "#/definitions/base_stream"
type: DeclarativeStream
$parameters:
name: "users"
primary_key: "user_id"
path: "users"
retriever:
type: SimpleRetriever
record_selector:
$ref: "#/definitions/selector"
paginator:
$ref: "#/definitions/paginator"
requester:
type: HttpRequester
url_base: "{{ config['base_url'] }}/api/v2"
path: "users"
http_method: "GET"
authenticator:
class_name: source_auth0.components.AuthenticatorAuth0
bearer: "#/definitions/bearer_authenticator"
oauth: "#/definitions/oauth_authenticator"
request_parameters:
sort: "updated_at:1"
include_totals: "false"
q: "updated_at:{{ '{' }}{{stream_interval.start_time ~ ' TO ' ~ stream_interval.end_time ~ ']' if stream_interval.start_time else config['start_date'] ~ ' TO *]'}}"
request_headers: {}
incremental_sync:
type: DatetimeBasedCursor
cursor_field: "updated_at"
datetime_format: "%Y-%m-%dT%H:%M:%S.%f%z"
cursor_granularity: "PT0.000001S"
datetime_format: "%Y-%m-%dT%H:%M:%S.%fZ"
cursor_granularity: "PT0.001S"
start_datetime:
datetime: "{{ config['start_date'] }}"
datetime_format: "%Y-%m-%dT%H:%M:%S.%f%z"
type: MinMaxDatetime
datetime: "{{ config.get('start_date', '2013-01-01T00:00:00.000Z') }}"
datetime_format: "%Y-%m-%dT%H:%M:%S.%fZ"
min_datetime: "2013-01-01T00:00:00.000Z"
end_datetime:
datetime: "{{ today_utc() }}"
datetime_format: "%Y-%m-%d"
step: "P1M"
type: MinMaxDatetime
datetime: "{{ now_utc().strftime('%Y-%m-%dT%H:%M:%S.%fZ') }}"
step: "P1Y"

organizations_stream:
$ref: "#/definitions/base_stream"
Expand Down
25 changes: 13 additions & 12 deletions docs/integrations/sources/auth0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ The source connector fetches data from [Auth0 Management API](https://auth0.com/

## Prerequisites

* You own an Auth0 account, free or paid.
* Follow the [Setup guide](#setup-guide) to authorize Airbyte to read data from your account.
- You own an Auth0 account, free or paid.
- Follow the [Setup guide](#setup-guide) to authorize Airbyte to read data from your account.

## Setup guide

Expand All @@ -30,14 +30,15 @@ The source connector fetches data from [Auth0 Management API](https://auth0.com/
2. In Auth0, go to [Dashboard > Applications > Applications](https://manage.auth0.com/?#/applications).
3. Create a new application, name it **Airbyte**. Choose the application type **Machine to Machine Applications**
4. Select the Management API V2, this is the api you want call from Airbyte.
5. Each M2M app that accesses an API must be granted a set of permissions (or scopes). Here, we only need permissions starting with `read` (e.g. *read:users*). Under the [API doc](https://auth0.com/docs/api/management/v2#!/Users/get_users), each api will list the required scopes.
5. Each M2M app that accesses an API must be granted a set of permissions (or scopes). Here, we only need permissions starting with `read` (e.g. _read:users_). Under the [API doc](https://auth0.com/docs/api/management/v2#!/Users/get_users), each api will list the required scopes.
6. More details can be found from [this documentation](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-access-tokens-for-production).

## Supported sync modes

The Auth0 source connector supports the following [sync modes](https://docs.airbyte.com/cloud/core-concepts#connection-sync-modes):
- Full Refresh
- Incremental

- Full Refresh
- Incremental

## Supported Streams

Expand All @@ -54,10 +55,10 @@ The connector is restricted by Auth0 [rate limits](https://auth0.com/docs/troubl

## Changelog

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------|
| 0.4.0 | 2023-08-03 | [28972](https://github.com/airbytehq/airbyte/pull/28972) | Migrate to Low-Code CDK |
| 0.3.0 | 2023-06-20 | [29001](https://github.com/airbytehq/airbyte/pull/29001) | Add Organizations, OrganizationMembers, OrganizationMemberRoles streams |
| 0.2.0 | 2023-05-23 | [26445](https://github.com/airbytehq/airbyte/pull/26445) | Add Clients stream |
| 0.1.0 | 2022-10-21 | [18338](https://github.com/airbytehq/airbyte/pull/18338) | Add Auth0 and Users stream |

| Version | Date | Pull Request | Subject |
| :------ | :--------- | :------------------------------------------------------- | :---------------------------------------------------------------------- |
| 0.4.1 | 2023-08-24 | [29804](https://github.com/airbytehq/airbyte/pull/29804) | Fix low code migration bugs |
| 0.4.0 | 2023-08-03 | [28972](https://github.com/airbytehq/airbyte/pull/28972) | Migrate to Low-Code CDK |
| 0.3.0 | 2023-06-20 | [29001](https://github.com/airbytehq/airbyte/pull/29001) | Add Organizations, OrganizationMembers, OrganizationMemberRoles streams |
| 0.2.0 | 2023-05-23 | [26445](https://github.com/airbytehq/airbyte/pull/26445) | Add Clients stream |
| 0.1.0 | 2022-10-21 | [18338](https://github.com/airbytehq/airbyte/pull/18338) | Add Auth0 and Users stream |

0 comments on commit db7a93e

Please sign in to comment.