auth_oidc: exclude disabled attributes in claim mapping form (#75474) #24

Open
pmarillonnet wants to merge 2 commits from wip/75474-auth-oidc-active-attributes-mapping into main
Owner
There is no content yet.
pmarillonnet added 1 commit 3 months ago
pmarillonnet added 1 commit 3 months ago
gitea/authentic/pipeline/head This commit looks good Details
b4d0bd5959
[WIP] auth_oidc: filter out disabled attributes (#75474)
pmarillonnet force-pushed wip/75474-auth-oidc-active-attributes-mapping from b4d0bd5959 to f079937e52 3 months ago
bdauvergne requested changes 2 months ago
@ -378,1 +378,4 @@
continue
# filter out inexistent or disabled attributes
if not Attribute.objects.filter(name=attribute):
continue
Owner

J'aurai plutôt vu ça à la source :

diff --git a/src/authentic2_auth_oidc/utils.py b/src/authentic2_auth_oidc/utils.py
index 45561f35..47acdef4 100644
--- a/src/authentic2_auth_oidc/utils.py
+++ b/src/authentic2_auth_oidc/utils.py
@@ -78,7 +78,11 @@ def parse_id_token(encoded, provider):
 
 def resolve_claim_mappings(provider, context, id_token=None, user_info=None):
     mappings = []
+    disabled = set(Attribute.all_objects.filter(disabled=True).values_list('name', flat=True))
     for claim_mapping in provider.claim_mappings.all():
+        attribute = claim_mapping.attribute
+        if attribute in disabled:
+            continue
         claim = claim_mapping.claim
         if id_token is None and user_info is None:
             source = context
@@ -89,7 +93,6 @@ def resolve_claim_mappings(provider, context, id_token=None, user_info=None):
         if not source or claim not in source and not ('{{' in claim or '{%' in claim):
             continue
         verified = False
-        attribute = claim_mapping.attribute
         if '{{' in claim or '{%' in claim:
             template = Template(claim)
             value = template.render(context=context)
J'aurai plutôt vu ça à la source : ``` diff --git a/src/authentic2_auth_oidc/utils.py b/src/authentic2_auth_oidc/utils.py index 45561f35..47acdef4 100644 --- a/src/authentic2_auth_oidc/utils.py +++ b/src/authentic2_auth_oidc/utils.py @@ -78,7 +78,11 @@ def parse_id_token(encoded, provider): def resolve_claim_mappings(provider, context, id_token=None, user_info=None): mappings = [] + disabled = set(Attribute.all_objects.filter(disabled=True).values_list('name', flat=True)) for claim_mapping in provider.claim_mappings.all(): + attribute = claim_mapping.attribute + if attribute in disabled: + continue claim = claim_mapping.claim if id_token is None and user_info is None: source = context @@ -89,7 +93,6 @@ def resolve_claim_mappings(provider, context, id_token=None, user_info=None): if not source or claim not in source and not ('{{' in claim or '{%' in claim): continue verified = False - attribute = claim_mapping.attribute if '{{' in claim or '{%' in claim: template = Template(claim) value = template.render(context=context) ```

Reviewers

bdauvergne requested changes 2 months ago
All checks were successful
gitea/authentic/pipeline/head This commit looks good
This pull request has changes conflicting with the target branch.
  • tests/test_auth_oidc.py
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b wip/75474-auth-oidc-active-attributes-mapping main
git pull origin wip/75474-auth-oidc-active-attributes-mapping

Step 2:

Merge the changes and update on Gitea.
git checkout main
git merge --no-ff wip/75474-auth-oidc-active-attributes-mapping
git push origin main
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: entrouvert/authentic#24
Loading…
There is no content yet.