Skip to content

fix(kratos): keep a user_metadata key named email, username or phone from overwriting the identifier trait - #138

Merged
emmanuelgautier merged 1 commit into
mainfrom
fix/kratos-metadata-identifier-collision
Nov 2, 2026
Merged

emmanuelgautier merged 1 commit into
mainfrom
fix/kratos-metadata-identifier-collision

Conversation

@emmanuelgautier

Copy link
Copy Markdown
Member

Fixes #79

Problem

The Kratos connector copied user_metadata into the identity's traits after setting email, username and phone from the user's identifiers, so a user_metadata key with one of those names silently overwrote the identifier trait.

Change

  • buildTraits now copies user_metadata first and sets the identifier traits afterwards, so the user's own identifiers win. The colliding value is still kept in metadata_public.
  • validate reports a user_metadata key named email, username or phone for Kratos, and points to a metadata: mapping route to move or drop it. The check applies with or without --schema-file.
  • Docs updated (validate reference and metadata mapping section).

Tests

Unit tests cover the precedence in buildIdentity and the new validation rule (including that app_metadata is unaffected). go test ./pkg/connector/kratos/ and go vet ./... pass; the live Kratos test was not run.

@emmanuelgautier
emmanuelgautier merged commit af81518 into main Nov 2, 2026
4 checks passed
@emmanuelgautier
emmanuelgautier deleted the fix/kratos-metadata-identifier-collision branch November 2, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kratos: a user_metadata key named email, username or phone overwrites the identifier trait

1 participant