Skip to content

Commit 85d3a9d

Browse files
feat(okta): custom properties for okta user (#12773)
1 parent a0319af commit 85d3a9d

5 files changed

+301
-157
lines changed

metadata-ingestion/src/datahub/ingestion/source/identity/okta.py

+22
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,27 @@ def _map_okta_user_profile_to_username(
666666
self.config.okta_profile_to_username_regex,
667667
)
668668

669+
def _map_okta_user_profile_custom_properties(
670+
self, profile: UserProfile
671+
) -> Dict[str, str]:
672+
# filter out the common fields that are already mapped to the CorpUserInfo aspect and the private ones
673+
return {
674+
k: str(v)
675+
for k, v in profile.__dict__.items()
676+
if v
677+
and k
678+
not in [
679+
"displayName",
680+
"firstName",
681+
"lastName",
682+
"email",
683+
"title",
684+
"countryCode",
685+
"department",
686+
]
687+
and not k.startswith("_")
688+
}
689+
669690
# Converts Okta User Profile into a CorpUserInfo.
670691
def _map_okta_user_profile(self, profile: UserProfile) -> CorpUserInfoClass:
671692
# TODO: Extract user's manager if provided.
@@ -683,6 +704,7 @@ def _map_okta_user_profile(self, profile: UserProfile) -> CorpUserInfoClass:
683704
title=profile.title,
684705
countryCode=profile.countryCode,
685706
departmentName=profile.department,
707+
customProperties=self._map_okta_user_profile_custom_properties(profile),
686708
)
687709

688710
def _make_corp_group_urn(self, name: str) -> str:

metadata-ingestion/tests/integration/okta/okta_mces_golden_custom_user_name_regex.json

+48-18
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"systemMetadata": {
2020
"lastObserved": 1586847600000,
21-
"runId": "test-okta-usage"
21+
"runId": "test-okta-usage",
22+
"lastRunId": "no-run-id-provided"
2223
}
2324
},
2425
{
@@ -34,7 +35,8 @@
3435
},
3536
"systemMetadata": {
3637
"lastObserved": 1586847600000,
37-
"runId": "test-okta-usage"
38+
"runId": "test-okta-usage",
39+
"lastRunId": "no-run-id-provided"
3840
}
3941
},
4042
{
@@ -49,7 +51,8 @@
4951
},
5052
"systemMetadata": {
5153
"lastObserved": 1586847600000,
52-
"runId": "test-okta-usage"
54+
"runId": "test-okta-usage",
55+
"lastRunId": "no-run-id-provided"
5356
}
5457
},
5558
{
@@ -71,7 +74,8 @@
7174
},
7275
"systemMetadata": {
7376
"lastObserved": 1586847600000,
74-
"runId": "test-okta-usage"
77+
"runId": "test-okta-usage",
78+
"lastRunId": "no-run-id-provided"
7579
}
7680
},
7781
{
@@ -87,7 +91,8 @@
8791
},
8892
"systemMetadata": {
8993
"lastObserved": 1586847600000,
90-
"runId": "test-okta-usage"
94+
"runId": "test-okta-usage",
95+
"lastRunId": "no-run-id-provided"
9196
}
9297
},
9398
{
@@ -102,7 +107,8 @@
102107
},
103108
"systemMetadata": {
104109
"lastObserved": 1586847600000,
105-
"runId": "test-okta-usage"
110+
"runId": "test-okta-usage",
111+
"lastRunId": "no-run-id-provided"
106112
}
107113
},
108114
{
@@ -112,12 +118,17 @@
112118
"aspects": [
113119
{
114120
"com.linkedin.pegasus2avro.identity.CorpUserInfo": {
121+
"customProperties": {
122+
"login": "[email protected]",
123+
"mobilePhone": "555-415-1337"
124+
},
115125
"active": true,
116126
"displayName": "JDoe",
117127
"email": "[email protected]",
118128
"firstName": "John",
119129
"lastName": "Doe",
120-
"fullName": "John Doe"
130+
"fullName": "John Doe",
131+
"system": false
121132
}
122133
},
123134
{
@@ -133,7 +144,8 @@
133144
},
134145
"systemMetadata": {
135146
"lastObserved": 1586847600000,
136-
"runId": "test-okta-usage"
147+
"runId": "test-okta-usage",
148+
"lastRunId": "no-run-id-provided"
137149
}
138150
},
139151
{
@@ -149,7 +161,8 @@
149161
},
150162
"systemMetadata": {
151163
"lastObserved": 1586847600000,
152-
"runId": "test-okta-usage"
164+
"runId": "test-okta-usage",
165+
"lastRunId": "no-run-id-provided"
153166
}
154167
},
155168
{
@@ -164,7 +177,8 @@
164177
},
165178
"systemMetadata": {
166179
"lastObserved": 1586847600000,
167-
"runId": "test-okta-usage"
180+
"runId": "test-okta-usage",
181+
"lastRunId": "no-run-id-provided"
168182
}
169183
},
170184
{
@@ -174,6 +188,10 @@
174188
"aspects": [
175189
{
176190
"com.linkedin.pegasus2avro.identity.CorpUserInfo": {
191+
"customProperties": {
192+
"login": "[email protected]",
193+
"mobilePhone": "666-415-1337"
194+
},
177195
"active": true,
178196
"displayName": "Mary Jane",
179197
"email": "[email protected]",
@@ -182,7 +200,8 @@
182200
"firstName": "Mary",
183201
"lastName": "Jane",
184202
"fullName": "Mary Jane",
185-
"countryCode": "us"
203+
"countryCode": "us",
204+
"system": false
186205
}
187206
},
188207
{
@@ -200,7 +219,8 @@
200219
},
201220
"systemMetadata": {
202221
"lastObserved": 1586847600000,
203-
"runId": "test-okta-usage"
222+
"runId": "test-okta-usage",
223+
"lastRunId": "no-run-id-provided"
204224
}
205225
},
206226
{
@@ -216,7 +236,8 @@
216236
},
217237
"systemMetadata": {
218238
"lastObserved": 1586847600000,
219-
"runId": "test-okta-usage"
239+
"runId": "test-okta-usage",
240+
"lastRunId": "no-run-id-provided"
220241
}
221242
},
222243
{
@@ -231,7 +252,8 @@
231252
},
232253
"systemMetadata": {
233254
"lastObserved": 1586847600000,
234-
"runId": "test-okta-usage"
255+
"runId": "test-okta-usage",
256+
"lastRunId": "no-run-id-provided"
235257
}
236258
},
237259
{
@@ -241,6 +263,10 @@
241263
"aspects": [
242264
{
243265
"com.linkedin.pegasus2avro.identity.CorpUserInfo": {
266+
"customProperties": {
267+
"login": "[email protected]",
268+
"mobilePhone": "666-415-1337"
269+
},
244270
"active": true,
245271
"displayName": "Good Test",
246272
"email": "[email protected]",
@@ -249,7 +275,8 @@
249275
"firstName": "Good",
250276
"lastName": "Test",
251277
"fullName": "Good Test",
252-
"countryCode": "eu"
278+
"countryCode": "eu",
279+
"system": false
253280
}
254281
},
255282
{
@@ -262,7 +289,8 @@
262289
},
263290
"systemMetadata": {
264291
"lastObserved": 1586847600000,
265-
"runId": "test-okta-usage"
292+
"runId": "test-okta-usage",
293+
"lastRunId": "no-run-id-provided"
266294
}
267295
},
268296
{
@@ -278,7 +306,8 @@
278306
},
279307
"systemMetadata": {
280308
"lastObserved": 1586847600000,
281-
"runId": "test-okta-usage"
309+
"runId": "test-okta-usage",
310+
"lastRunId": "no-run-id-provided"
282311
}
283312
},
284313
{
@@ -293,7 +322,8 @@
293322
},
294323
"systemMetadata": {
295324
"lastObserved": 1586847600000,
296-
"runId": "test-okta-usage"
325+
"runId": "test-okta-usage",
326+
"lastRunId": "no-run-id-provided"
297327
}
298328
}
299329
]

0 commit comments

Comments
 (0)