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

feat(okta): custom properties for okta user #12773

Merged
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
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()
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this a safe thing to do? maybe we should also check that not k.startswith('_')?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 79a201f

Copy link
Contributor Author

Choose a reason for hiding this comment

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

about safety... well, it was safe for UserProfile

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
Loading