goauthentik / goauthentik/authentik

FR - Property Mapping - Define a 'source of truth' source that wins when multiple sources are used.

Open
#26,083 0 comments 0 reactions 0 assignees View on GitHub
enhancement triage
Dominant language
Python
Stars
25.6k
Forks
2k
Avg merge
1d 1h
Merged PRs (30d)
644

Description

### Is your feature request related to a problem?

I've run into a headache where if I use property mappings and then a user write stage, if i don't an expression to strip extraneous data, it overwrites fields that i didn't want updated. Side-note. Property Mappings seem to handle group updates on login without the write stage, but attributes only sync the first time and never again unless I set up a write stage.

Example where I only want discord updating attributes, but not key properties like Username or Name. I'm sure there's a better way to do this, but this was a quick and dirty solution.

```python
from authentik.sources.oauth.models import OAuthSource

if not isinstance(context['source'], OAuthSource) or context['source'].provider_type != "discord":
return True

DOMAIN_TO_SKIP = 'example.org'

if request.context["pending_user"].email.split('@')[-1] == DOMAIN_TO_SKIP:
non_attribute_keys = [ key for key in request.context['prompt_data'] if key != 'attributes' ]
for key in non_attribute_keys:
removed_key = request.context["prompt_data"].pop(key, None)

return True
```

### Describe the solution you'd like

A priority list to define which sources are primary, or an option to define what to sync from sources if a value exists alread.

### Describe alternatives that you've considered

A hacky shim that just strips out data before doing the write in the auth flow. Seems a little heavy

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by tracing how property mappings and the user write stage process source data during authentication, using the issue's Discord example as the reproduction case. Compare the existing group and attribute synchronization behavior, then define how source precedence or selective synchronization should be specified and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
authentication
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.