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 Okta: add User_Role_Assignments and Group_Role_Assignments #14556

Merged
merged 5 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
- name: Okta
sourceDefinitionId: 1d4fdb25-64fc-4569-92da-fcdca79a8372
dockerRepository: airbyte/source-okta
dockerImageTag: 0.1.6
dockerImageTag: 0.1.7
documentationUrl: https://docs.airbyte.io/integrations/sources/okta
icon: okta.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6030,7 +6030,7 @@
- - "client_secret"
oauthFlowOutputParameters:
- - "access_token"
- dockerImage: "airbyte/source-okta:0.1.6"
- dockerImage: "airbyte/source-okta:0.1.7"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/okta"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-okta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.6
LABEL io.airbyte.version=0.1.7
LABEL io.airbyte.name=airbyte/source-okta
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
},
{
"stream": {
"name": "user_role_assignments",
"json_schema": {}
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
},
{
"stream": {
"name": "group_role_assignments",
"json_schema": {}
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "user_role_assignments",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "group_role_assignments",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@
"destination_sync_mode": "overwrite",
"cursor_field": ["id"],
"primary_key": [["id"]]
},
{
"stream": {
"name": "user_role_assignments",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
},
{
"stream": {
"name": "group_role_assignments",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",
"primary_key": [["id"]]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"$ref": "users.json"
"$ref": "shared-user.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$ref": "shared-role.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"properties": {
"id": {
"type": "string"
},
"label": {
"type": "string"
},
"type": {
"enum": [
"API_ACCESS_MANAGEMENT_ADMIN",
"APP_ADMIN",
"GROUP_MEMBERSHIP_ADMIN",
"HELP_DESK_ADMIN",
"MOBILE_ADMIN",
"ORG_ADMIN",
"READ_ONLY_ADMIN",
"REPORT_ADMIN",
"SUPER_ADMIN",
"USER_ADMIN",
"CUSTOM"
],
"type": "string"
},
"status": {
"enum": [
"ACTIVE",
"DEPROVISIONED",
"LOCKED_OUT",
"PASSWORD_EXPIRED",
"PROVISIONED",
"RECOVERY",
"STAGED",
"SUSPENDED"
],
"type": "string"
},
"created": {
"format": "date-time",
"type": "string"
},
"lastUpdated": {
"format": "date-time",
"type": "string"
},
"assignmentType": {
"enum": ["USER", "GROUP"],
"type": "string"
},
"resource-set": {
"description": "The Resource Set ID in which the Role is granted (only present for Custom Roles)",
"type": ["string", "null"]
},
"_links": {
"properties": {
"assignee": {
"properties": {
"assignee": {
"$ref": "shared-link.json",
"description": "Gets the User or Group through which this Role is assigned"
},
"role": {
"$ref": "shared-link.json",
"description": "(Only for Custom Roles) gets the Role that is granted through this assignment"
},
"resource-set": {
"$ref": "shared-link.json",
"description": "(Only for Custom Roles) Gets the Resource Set that is targeted by this assignment"
},
"permissions": {
"$ref": "shared-link.json",
"description": "(Only for Custom Roles) Gets a list of Permissions that is granted through this assignment"
},
"member": {
"$ref": "shared-link.json",
"description": "(Only for Custom Roles) gets the Member object from the Binding that grants this Role"
}
}
}
},
"type": ["object", "null"]
}
},
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$id": "shared-users.json",
"properties": {
"_links": {
"additionalProperties": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$ref": "shared-role.json"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"$ref": "users.json"
"$ref": "shared-user.json"
}
30 changes: 30 additions & 0 deletions airbyte-integrations/connectors/source-okta/source_okta/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ def get_updated_state(self, current_stream_state: MutableMapping[str, Any], late
}


class GroupRoleAssignments(OktaStream):
primary_key = "id"
use_cache = True

def stream_slices(self, **kwargs):
group_stream = Groups(authenticator=self.authenticator, url_base=self.url_base)
for group in group_stream.read_records(sync_mode=SyncMode.full_refresh):
yield {"group_id": group["id"]}

def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
group_id = stream_slice["group_id"]
return f"groups/{group_id}/roles"


class Logs(IncrementalOktaStream):

cursor_field = "published"
Expand Down Expand Up @@ -204,6 +218,20 @@ def parse_response(
yield from response.json()["roles"]


class UserRoleAssignments(OktaStream):
primary_key = "id"
use_cache = True

def stream_slices(self, **kwargs):
user_stream = Users(authenticator=self.authenticator, url_base=self.url_base)
for user in user_stream.read_records(sync_mode=SyncMode.full_refresh):
yield {"user_id": user["id"]}

def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
user_id = stream_slice["user_id"]
return f"users/{user_id}/roles"


class SourceOkta(AbstractSource):
def initialize_authenticator(self, config: Mapping[str, Any]) -> TokenAuthenticator:
return TokenAuthenticator(config["token"], auth_method="SSWS")
Expand Down Expand Up @@ -245,4 +273,6 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
Users(**initialization_params),
GroupMembers(**initialization_params),
CustomRoles(**initialization_params),
UserRoleAssignments(**initialization_params),
GroupRoleAssignments(**initialization_params),
]
54 changes: 28 additions & 26 deletions docs/integrations/sources/okta.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ This source can sync data for the [Okta API](https://developer.okta.com/docs/ref

This Source is capable of syncing the following core Streams:

* [Users](https://developer.okta.com/docs/reference/api/users/#list-users)
* [Groups](https://developer.okta.com/docs/reference/api/groups/#list-groups)
* [Group Members](https://developer.okta.com/docs/reference/api/groups/#list-group-members)
* [System Log](https://developer.okta.com/docs/reference/api/system-log/#get-started)
* [Custom Roles](https://developer.okta.com/docs/reference/api/roles/#list-roles)
- [Users](https://developer.okta.com/docs/reference/api/users/#list-users)
- [User Role Assignments](https://developer.okta.com/docs/reference/api/roles/#list-roles-assigned-to-a-user)
- [Groups](https://developer.okta.com/docs/reference/api/groups/#list-groups)
- [Group Members](https://developer.okta.com/docs/reference/api/groups/#list-group-members)
- [Group Role Assignments](https://developer.okta.com/docs/reference/api/roles/#list-roles-assigned-to-a-group)
- [System Log](https://developer.okta.com/docs/reference/api/system-log/#get-started)
- [Custom Roles](https://developer.okta.com/docs/reference/api/roles/#list-roles)

### Data type mapping

| Integration Type | Airbyte Type | Notes |
| :--- | :--- | :--- |
| `string` | `string` | |
| `number` | `number` | |
| `array` | `array` | |
| `object` | `object` | |
| :--------------- | :----------- | :---- |
| `string` | `string` | |
| `number` | `number` | |
| `array` | `array` | |
| `object` | `object` | |

### Features

| Feature | Supported?\(Yes/No\) | Notes |
| :--- | :--- | :--- |
| Full Refresh Sync | Yes | |
| Incremental Sync | Yes | |
| Namespaces | No | |
| Feature | Supported?\(Yes/No\) | Notes |
| :---------------- | :------------------- | :---- |
| Full Refresh Sync | Yes | |
| Incremental Sync | Yes | |
| Namespaces | No | |

### Performance considerations

Expand All @@ -39,7 +41,7 @@ The connector is restricted by normal Okta [requests limitation](https://develop

### Requirements

* Okta API Token
- Okta API Token

### Setup guide

Expand All @@ -61,13 +63,13 @@ Different Okta APIs require different admin privilege levels. API tokens inherit

## Changelog

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.6 | 2022-07-11 | [14610](https://github.com/airbytehq/airbyte/pull/14610) | add custom roles stream |
| 0.1.5 | 2022-07-04 | [14380](https://github.com/airbytehq/airbyte/pull/14380) | add Group_Members stream to okta source |
| 0.1.4 | 2021-11-02 | [7584](https://github.com/airbytehq/airbyte/pull/7584) | Fix incremental params for log stream |
| 0.1.3 | 2021-09-08 | [5905](https://github.com/airbytehq/airbyte/pull/5905) | Fix incremental stream defect |
| 0.1.2 | 2021-07-01 | [4456](https://github.com/airbytehq/airbyte/pull/4456) | Bugfix infinite pagination in logs stream |
| 0.1.1 | 2021-06-09 | [3937](https://github.com/airbytehq/airbyte/pull/3973) | Add `AIRBYTE_ENTRYPOINT` env variable for kubernetes support |
| 0.1.0 | 2021-05-30 | [3563](https://github.com/airbytehq/airbyte/pull/3563) | Initial Release |

| Version | Date | Pull Request | Subject |
| :------ | :--------- | :------------------------------------------------------- | :----------------------------------------------------------------------------- |
| 0.1.7 | 2022-07-13 | [14556](https://github.com/airbytehq/airbyte/pull/14556) | add User_Role_Assignments and Group_Role_Assignments streams (full fetch only) |
| 0.1.6 | 2022-07-11 | [14610](https://github.com/airbytehq/airbyte/pull/14610) | add custom roles stream |
| 0.1.5 | 2022-07-04 | [14380](https://github.com/airbytehq/airbyte/pull/14380) | add Group_Members stream to okta source |
| 0.1.4 | 2021-11-02 | [7584](https://github.com/airbytehq/airbyte/pull/7584) | Fix incremental params for log stream |
| 0.1.3 | 2021-09-08 | [5905](https://github.com/airbytehq/airbyte/pull/5905) | Fix incremental stream defect |
| 0.1.2 | 2021-07-01 | [4456](https://github.com/airbytehq/airbyte/pull/4456) | Bugfix infinite pagination in logs stream |
| 0.1.1 | 2021-06-09 | [3937](https://github.com/airbytehq/airbyte/pull/3973) | Add `AIRBYTE_ENTRYPOINT` env variable for kubernetes support |
| 0.1.0 | 2021-05-30 | [3563](https://github.com/airbytehq/airbyte/pull/3563) | Initial Release |