Skip to content

Commit

Permalink
feat(okta): custom properties for okta user (#12773)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomezvillamor authored Mar 5, 2025
1 parent a0319af commit 85d3a9d
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 157 deletions.
22 changes: 22 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/source/identity/okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,27 @@ def _map_okta_user_profile_to_username(
self.config.okta_profile_to_username_regex,
)

def _map_okta_user_profile_custom_properties(
self, profile: UserProfile
) -> Dict[str, str]:
# filter out the common fields that are already mapped to the CorpUserInfo aspect and the private ones
return {
k: str(v)
for k, v in profile.__dict__.items()
if v
and k
not in [
"displayName",
"firstName",
"lastName",
"email",
"title",
"countryCode",
"department",
]
and not k.startswith("_")
}

# Converts Okta User Profile into a CorpUserInfo.
def _map_okta_user_profile(self, profile: UserProfile) -> CorpUserInfoClass:
# TODO: Extract user's manager if provided.
Expand All @@ -683,6 +704,7 @@ def _map_okta_user_profile(self, profile: UserProfile) -> CorpUserInfoClass:
title=profile.title,
countryCode=profile.countryCode,
departmentName=profile.department,
customProperties=self._map_okta_user_profile_custom_properties(profile),
)

def _make_corp_group_urn(self, name: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -34,7 +35,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -49,7 +51,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -71,7 +74,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -87,7 +91,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -102,7 +107,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -112,12 +118,17 @@
"aspects": [
{
"com.linkedin.pegasus2avro.identity.CorpUserInfo": {
"customProperties": {
"login": "john.doe@test.com",
"mobilePhone": "555-415-1337"
},
"active": true,
"displayName": "JDoe",
"email": "john.doe@test.com",
"firstName": "John",
"lastName": "Doe",
"fullName": "John Doe"
"fullName": "John Doe",
"system": false
}
},
{
Expand All @@ -133,7 +144,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -149,7 +161,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -164,7 +177,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -174,6 +188,10 @@
"aspects": [
{
"com.linkedin.pegasus2avro.identity.CorpUserInfo": {
"customProperties": {
"login": "mary.jane@test.com",
"mobilePhone": "666-415-1337"
},
"active": true,
"displayName": "Mary Jane",
"email": "mary.jane@test.com",
Expand All @@ -182,7 +200,8 @@
"firstName": "Mary",
"lastName": "Jane",
"fullName": "Mary Jane",
"countryCode": "us"
"countryCode": "us",
"system": false
}
},
{
Expand All @@ -200,7 +219,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -216,7 +236,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -231,7 +252,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -241,6 +263,10 @@
"aspects": [
{
"com.linkedin.pegasus2avro.identity.CorpUserInfo": {
"customProperties": {
"login": "good.test@test.com",
"mobilePhone": "666-415-1337"
},
"active": true,
"displayName": "Good Test",
"email": "good.test@test.com",
Expand All @@ -249,7 +275,8 @@
"firstName": "Good",
"lastName": "Test",
"fullName": "Good Test",
"countryCode": "eu"
"countryCode": "eu",
"system": false
}
},
{
Expand All @@ -262,7 +289,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -278,7 +306,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -293,7 +322,8 @@
},
"systemMetadata": {
"lastObserved": 1586847600000,
"runId": "test-okta-usage"
"runId": "test-okta-usage",
"lastRunId": "no-run-id-provided"
}
}
]
Loading

0 comments on commit 85d3a9d

Please sign in to comment.