[PR #8818] fix(sso): provisionUser inconsistency and option to run on every login #16481

Closed
opened 2026-04-13 10:32:17 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8818

State: closed
Merged: Yes


closes https://github.com/better-auth/better-auth/issues/8630

Previously a isRegister check was added to prevent provisionUser from running on every login to the OIDC provider. This PR does add this behaviour to SAML as well to remove this inconsistency.

As some users (including me) will have the need to update the users profile info also for returning users, I also added an option provisionUserOnEveryLogin: true, so that provisionUser is called on every login.


Summary by cubic

Aligns SAML with OIDC so provisionUser runs only on first sign-in by default, and adds provisionUserOnEveryLogin to call it on every login when needed. This enables reliable profile sync from upstream IdPs while keeping safe defaults.

  • New Features

    • Added provisionUserOnEveryLogin in SSOOptions; when true, provisionUser runs on every sign-in across OIDC and SAML.
    • Updated docs with usage, defaults, and idempotency guidance.
  • Bug Fixes

    • SAML now matches OIDC: call provisionUser only on registration by default.
    • Added OIDC and SAML tests to cover first vs subsequent logins.

Written for commit f7acec8e95. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8818 **State:** closed **Merged:** Yes --- closes https://github.com/better-auth/better-auth/issues/8630 Previously a isRegister check was added to prevent provisionUser from running on every login to the OIDC provider. This PR does add this behaviour to SAML as well to remove this inconsistency. As some users (including me) will have the need to update the users profile info also for returning users, I also added an option `provisionUserOnEveryLogin: true`, so that `provisionUser` is called on every login. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Aligns SAML with OIDC so `provisionUser` runs only on first sign-in by default, and adds `provisionUserOnEveryLogin` to call it on every login when needed. This enables reliable profile sync from upstream IdPs while keeping safe defaults. - **New Features** - Added `provisionUserOnEveryLogin` in `SSOOptions`; when true, `provisionUser` runs on every sign-in across OIDC and SAML. - Updated docs with usage, defaults, and idempotency guidance. - **Bug Fixes** - SAML now matches OIDC: call `provisionUser` only on registration by default. - Added OIDC and SAML tests to cover first vs subsequent logins. <sup>Written for commit f7acec8e9596984510d85b3743a03c238e2f55bd. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:32:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16481