Skip to content

Commit

Permalink
feat: [ACI-940, ACI-941] implement keypaths exclusion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii committed Apr 24, 2024
1 parent 04aeae2 commit ccdc59c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 10 additions & 2 deletions credentials/apps/badges/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,23 @@ def get_data_keypaths(data):
keypaths = []
for field in attr.fields(data):
if attr.has(field.type):
keypaths += [f"{field.name}.{keypath}" for keypath in get_data_keypaths(field.type)]
keypaths += [
f"{field.name}.{keypath}"
for keypath in get_data_keypaths(field.type)
]
else:
keypaths.append(field.name)
return keypaths

keypaths = []
for field in attr.fields(data):
if attr.has(field.type):
keypaths += [f"{field.name}.{keypath}" for keypath in get_data_keypaths(field.type)]
keypaths += [
f"{field.name}.{keypath}"
for keypath in get_data_keypaths(field.type)
if f"{field.name}.{keypath}"
not in settings.BADGES_CONFIG["EXCLUDED_KEY_PATHS"]
]
else:
keypaths.append(field.name)
return keypaths
7 changes: 7 additions & 0 deletions credentials/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,11 @@
"CREDLY_SANDBOX_API_BASE_URL": "https://sandbox-api.credly.com/v1/",
"USE_SANDBOX": False,
},
"EXCLUDED_KEY_PATHS": [
"user.id",
"user.is_active",
"user.pii.username",
"user.pii.email",
"user.pii.name",
]
}

0 comments on commit ccdc59c

Please sign in to comment.