Skip to content

core, web: make list merging configurable on property mappings - #27283

Closed
dominic-r wants to merge 6 commits into
mainfrom
dominic/property-mapping-merge-unique-lists
Closed

dominic-r wants to merge 6 commits into
mainfrom
dominic/property-mapping-merge-unique-lists

Conversation

@dominic-r

@dominic-r dominic-r commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Details

What does this PR change?

Scope mappings, synchronization mappings (SCIM, Google Workspace, Microsoft Entra) and source property mappings get a List merging setting. It decides how a list that the mapping returns is combined with the list under the same key that mappings evaluated before it returned:

  • Append adds every item.
  • Append unique items adds only items that are not already in the list.
  • Replace discards the earlier list.

The setting applies to lists at any depth. Dictionaries and other values merge as before. Defaults keep today's behavior: scope and synchronization mappings append, and source mappings append unique items. Existing mappings get the same defaults through the migrations.

Because the mode of the mapping evaluated later decides, scope mappings that share a scope name are now ordered by name too, so the order is stable. The OpenID discovery document also lists each claim once in claims_supported.

The admin forms for those mapping types show the setting with the type's default. SAML, RADIUS, RAC and notification mappings don't merge results, so they don't get the field. The docs for provider and source property mappings describe the setting.

Why is this change needed?

The stock profile scope mapping and a custom groups scope mapping both return groups, so the userinfo response and the ID token listed every group twice (#25842). Outgoing sync had the same problem: two SCIM mappings that each return the core user schema in schemas sent it twice.

No single rule fits every setup. Append duplicates values, while de-duplicating drops repeated values that some services expect. Making it a setting on the mapping lets admins fix the duplicate groups by setting the profile mapping to Append unique items, without changing what other setups receive. Replace also lets an OAuth source mapping substitute plain identifiers for object-shaped groups claims instead of adding them to the collected list.

The issue also suggests removing groups from the stock profile mapping. This PR keeps it. Integration guides such as Dashy, Homarr and NetBox rely on it, so removing it would silently drop the group claim for those applications.

How was this tested?

Added regression tests:

  • userinfo with the stock profile mapping and a custom groups mapping returns the groups twice with Append, once with Append unique items, and only the profile mapping's groups with Replace;
  • a SCIM user built from two mappings that both return the core schema in schemas lists it twice with the default and once with Append unique items;
  • a source with two mappings that return overlapping lists produces each of the three results, and new source mappings default to Append unique items;
  • the discovery document lists sub and groups once when a custom mapping also returns them.

The existing OAuth2, SCIM, Google Workspace, Entra, LDAP, OAuth, SAML and SCIM source tests pass. I couldn't run the Kerberos source tests, which need a local Kerberos install, and I didn't test the admin form or a live OIDC client in a browser.

Linked issues

Closes #25842
refs #27284 (docs)


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

OAuth2 claims and outgoing sync data were merged with deepmerge's
always_merger, which appends lists. A list returned by two mappings
therefore contained every item twice, for example `groups` from the
stock `profile` mapping and a custom `groups` mapping. Merge with
MERGE_LIST_UNIQUE instead, as source property mappings already do.
The discovery document listed such claims twice in `claims_supported`
for the same reason.

The stock `profile` mapping keeps its `groups` claim. It has been
there since the mapping was created, the docs list group membership as
part of `profile`, and integrations rely on it.

Closes: #25842
@dominic-r dominic-r added area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 labels Oct 27, 2026
@dominic-r
dominic-r requested a review from a team as a code owner October 27, 2026 22:45
@dominic-r dominic-r self-assigned this Oct 27, 2026
@netlify

netlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 3133775
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6aea3794f0a8909dd106b4be
😎 Deploy Preview https://deploy-preview-27283--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (bbd324f) to head (7b45b6b).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #27283   +/-   ##
=======================================
  Coverage   93.00%   93.01%           
=======================================
  Files        1226     1226           
  Lines       85284    85345   +61     
  Branches     4894     4894           
=======================================
+ Hits        79322    79384   +62     
+ Misses       5875     5874    -1     
  Partials       87       87           
Flag Coverage Δ
conformance 30.57% <45.65%> (+<0.01%) ⬆️
e2e 35.29% <46.73%> (-0.01%) ⬇️
integration 28.04% <42.39%> (+0.01%) ⬆️
rust 51.12% <ø> (ø)
unit 94.54% <100.00%> (+<0.01%) ⬆️
unit-migrate 94.55% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Playwright e2e

Download this run's HTML report and traces, then open the report:

gh run download 41862923311 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-report

Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-ce1a6c96dd63e461d176d8e5aa088fa4eac6525f
# Distroless image: AUTHENTIK_TAG=gh-ce1a6c96dd63e461d176d8e5aa088fa4eac6525f-distroless
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-ce1a6c96dd63e461d176d8e5aa088fa4eac6525f
        # Distroless image: tag: gh-ce1a6c96dd63e461d176d8e5aa088fa4eac6525f-distroless

Afterwards, run the upgrade commands from the latest release notes.

@BeryJu BeryJu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no matter what we change this to, its always gonna be the incorrect way for certain use-cases

one way around this would be to make the merging configurable (I think the most sensible location for that would be on the mapping, but that might have some impact performance wise for using different methods for merging per mapping, but probably negligable..?)

No single rule for combining lists that several mappings return fits
every setup: appending duplicates groups when two scope mappings return
them, while de-duplicating drops repeated values that some services
expect. Scope, synchronization and source property mappings now have a
list merge mode (append, append unique, or replace) that decides how the
lists a mapping returns merge into the results of the mappings evaluated
before it.

Defaults keep today's behavior: scope and synchronization mappings
append, and source mappings append unique items. Scope mappings that
share a scope name are now also ordered by name, so which mapping is
evaluated later is stable.
@dominic-r
dominic-r requested review from a team as code owners October 30, 2026 04:26
@dominic-r dominic-r changed the title providers/oauth2, lib/sync: de-duplicate lists merged from mappings core, web: make list merging configurable on property mappings Oct 30, 2026
@dominic-r
dominic-r requested a review from BeryJu October 30, 2026 04:26
@dominic-r dominic-r closed this Nov 7, 2026
@dominic-r
dominic-r deleted the dominic/property-mapping-merge-unique-lists branch November 7, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stock 'profile' scope mapping unexpectedly includes a 'groups' field, causing duplicate group entries when combined with a custom 'groups' scope mapping

3 participants