Skip to content

Commit

Permalink
feat(ingest/okta): option to only ingest users from filtered groups (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored Jan 30, 2024
1 parent d1604b3 commit 8559eba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/source/identity/okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ class OktaConfig(StatefulIngestionConfigBase, ConfigModel):
default=None,
description="Okta search expression (not regex) for ingesting groups. Only one of `okta_groups_filter` and `okta_groups_search` can be set. See (https://developer.okta.com/docs/reference/api/groups/#list-groups-with-search) for more info.",
)
skip_users_without_a_group: bool = Field(
default=False,
description="Whether to only ingest users that are members of groups. If this is set to False, all users will be ingested regardless of group membership.",
)

# Configuration for stateful ingestion
stateful_ingestion: Optional[StatefulStaleMetadataRemovalConfig] = Field(
Expand Down Expand Up @@ -387,6 +391,15 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
datahub_corp_user_snapshot.urn
]
)
if (
self.config.skip_users_without_a_group
and len(datahub_group_membership.groups) == 0
):
logger.debug(
f"Filtering {datahub_corp_user_snapshot.urn} due to group filter"
)
self.report.report_filtered(datahub_corp_user_snapshot.urn)
continue
assert datahub_group_membership is not None
datahub_corp_user_snapshot.aspects.append(datahub_group_membership)
mce = MetadataChangeEvent(proposedSnapshot=datahub_corp_user_snapshot)
Expand Down

0 comments on commit 8559eba

Please sign in to comment.