Skip to content

[17.0][ADD] auth_oauth_link_by_email: add new module to allow linking OAuth accounts by email#941

Open
zamberjo wants to merge 1 commit into
OCA:17.0from
heligrafics:add/oidc-link-by-email
Open

[17.0][ADD] auth_oauth_link_by_email: add new module to allow linking OAuth accounts by email#941
zamberjo wants to merge 1 commit into
OCA:17.0from
heligrafics:add/oidc-link-by-email

Conversation

@zamberjo
Copy link
Copy Markdown
Member

@zamberjo zamberjo commented May 18, 2026

When existing Odoo users (created before OAuth/OIDC was configured) try to log in via an OAuth provider, the system fails to find them because their oauth_uid is not set, falling through to signup and failing.

This module adds an auto-link mechanism: on first OAuth login, if no user is found by oauth_uid, it attempts to match an existing active user whose login equals the email claim from the token, linking them automatically by writing the oauth_uid and oauth_provider_id.

Subsequent logins use the standard oauth_uid lookup with no extra queries.

Usage: install auth_oauth_link_by_email — no configuration needed.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @sbidoul,
some modules you are maintaining are being modified, check this out!

@sbidoul
Copy link
Copy Markdown
Member

sbidoul commented May 18, 2026

Hi! auth_oidc has a mechanism to control token fields mapping (see token_map field). Is that not sufficient for your use case?

@zamberjo
Copy link
Copy Markdown
Member Author

Hi! The issue is that existing users have an empty (False) oauth_uid, so _auth_oauth_signin cannot find them during the lookup:

self.search([("oauth_uid", "=", oauth_uid), ("oauth_provider_id", "=", provider)])

Even if token_map is configured with something like email:user_id, existing users still won't have that mapped value stored in oauth_uid

@zamberjo zamberjo force-pushed the add/oidc-link-by-email branch 2 times, most recently from cc1ae94 to 06d7655 Compare May 18, 2026 11:23
@zamberjo zamberjo marked this pull request as ready for review May 18, 2026 11:26
@sbidoul
Copy link
Copy Markdown
Member

sbidoul commented May 18, 2026

Ah, I see. Then you probably need to create a new module that depends on auth_oauth and/or auth_signup as this feature is not releated to OpenID Connect but more to the generic oauth signup feature..

@zamberjo zamberjo force-pushed the add/oidc-link-by-email branch from 06d7655 to 2efdb3a Compare May 18, 2026 13:25
@OCA-git-bot OCA-git-bot added mod:auth_oauth_link_by_email Module auth_oauth_link_by_email and removed mod:auth_oidc Module auth_oidc labels May 18, 2026
@zamberjo zamberjo changed the title [17.0][IMP] auth_oidc: allow optional linking by email [17.0][Add] auth_oauth_link_by_email: add new module May 18, 2026
@zamberjo zamberjo changed the title [17.0][Add] auth_oauth_link_by_email: add new module [17.0][ADD] auth_oauth_link_by_email: add new module to allow linking OAuth accounts by email May 18, 2026
@zamberjo zamberjo marked this pull request as draft May 18, 2026 13:36
@zamberjo zamberjo marked this pull request as ready for review May 18, 2026 13:48
@zamberjo
Copy link
Copy Markdown
Member Author

Ah, I see. Then you probably need to create a new module that depends on auth_oauth and/or auth_signup as this feature is not releated to OpenID Connect but more to the generic oauth signup feature..

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants