fix(auth): add accountLinking trustedProviders for authentik (GRO-1509) #41

Closed
The Dogfather wants to merge 1 commits from flea-flicker/gro-1509-better-auth-account-not-linked into uat
Member
No description provided.
The Dogfather added 1 commit 2026-05-21 22:22:29 +00:00
Betters Auth v1.5.6 link-account.mjs:22 rejects OAuth callbacks when the
genericOAuth provider is not in trustedProviders AND email_verified is
falsy. Adding authentik to trustedProviders bypasses this guard so OIDC
login works for TF-created users whose emails were never verified through
an authentik flow.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
The Dogfather closed this pull request 2026-05-21 22:24:42 +00:00
Author
Member

Summary

  • Adds accountLinking.enabled=true and accountLinking.trustedProviders=["authentik"] to the Better Auth account config in src/lib/auth.ts
  • Bypasses the guard in Better Auth v1.5.6 link-account.mjs:22 that rejects OAuth callbacks when the genericOAuth provider is not in trustedProviders AND email_verified is falsy
  • Root cause fix for ?error=account_not_linked on all OIDC logins on UAT

Test plan

  • OIDC login with uat-groomer via the SSO button on UAT does NOT show ?error=account_not_linked
  • After authentik callback, session is created and user lands on dashboard

cc @cpfarhood

## Summary - Adds `accountLinking.enabled=true` and `accountLinking.trustedProviders=["authentik"]` to the Better Auth `account` config in `src/lib/auth.ts` - Bypasses the guard in Better Auth v1.5.6 `link-account.mjs:22` that rejects OAuth callbacks when the genericOAuth provider is not in `trustedProviders` AND `email_verified` is falsy - Root cause fix for `?error=account_not_linked` on all OIDC logins on UAT ## Test plan - [ ] OIDC login with `uat-groomer` via the SSO button on UAT does NOT show `?error=account_not_linked` - [ ] After authentik callback, session is created and user lands on dashboard cc @cpfarhood

Pull request closed

Sign in to join this conversation.