22 Commits
Author SHA1 Message Date
Andras Bacsai 5fd7191d4a fix(auth): allow OAuth sign-up with an unverified provider email
The provider email verification check now runs only when an account with
that email already exists. A new account follows the registration
settings, the same way password registration does, which also doesn't
verify the email. Linking to an existing account still needs a verified
email, except for password-less users created before OAuth identities.

Add tests for new-user registration from Authentik, Discord and GitLab
when the provider email is unverified. Also test that the "Registration
is disabled" error is shown when registration is turned off.
2026-10-02 17:07:54 +02:00
Andras Bacsai 5b1fcd6e13 feat(auth): show OAuth-only registration notice on login page
Move the user creation check from OauthLoginService into
OauthSetting::allowsUserCreation(), so the login view can use it.
The login view now gets a can_register_with_oauth flag. The flag is
true when an enabled OAuth provider allows creating new users. The
view uses it to show the new auth.register_with_oauth message.
Add translations for the message in all locales, plus test coverage.
2026-10-02 16:45:33 +02:00
Andras Bacsai b1ddde2b64 fix(auth): enforce Google hosted domain and block password-user linking
Treat the Google "Hosted domain" setting as an enforced Workspace
restriction: compare it to the hd claim case-insensitively with spaces
trimmed, and accept "*" for any Workspace account while still rejecting
personal Google accounts.

Exempt pre-upgrade OAuth users from the email verification check only
when they have no password. A flagged user with a password no longer gets
an unverified provider email linked to their account.

Update the hosted domain helper text and add tests for both cases.
2026-10-02 16:11:21 +02:00
Andras Bacsai 8521f973dd fix(auth): show specific error messages for denied OAuth logins
Add OauthLoginException, which carries a translation key for the message
shown on the login page. The exception message only goes to the log.
OauthLoginService now throws it for an unverified email, an account that
is already linked to another identity, and disabled registration.
OauthController shows the matching message for each case. Other
HttpExceptions fall back to a generic OAuth failure message.

The email verification check now runs before the linked-identity check,
so an unverified email cannot reveal that an account is already linked.

Add translations for the new auth.failed.oauth* keys in all locales and
cover the new error messages with feature tests.
2026-10-02 16:07:48 +02:00
Andras BacsaiandClaude Opus 5.5 3dabda5c56 fix(oauth): require a verified provider email for password users and use the instance callback URL
- Only password-less users from before OAuth identities skip the provider
  email verification claim. Otherwise an unverified provider account with
  the email of a password user (including root) could sign in as them.
- Build the default callback URL from the instance URL, not the request
  Host header, and do not save it during a login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 16:01:10 +02:00
Andras Bacsai b8bc197b17 fix(oauth): key non-OIDC identities by provider instance
GitLab, Authentik, Zitadel, Clerk and Azure identities were keyed by the
provider name only, so a user with the same subject on another instance
could sign in as the linked user after the base URL or tenant changed.
The issuer column now stores the normalized instance, existing rows are
backfilled from the current settings, and oauth:rekey handles host renames.
2026-09-30 18:10:10 +02:00
Andras Bacsai f9e5a00312 fix(oauth): let pre-existing users link first identity without verification
Before OAuth identities existed, OAuth sign-in matched users by email
only. Add a created_before_oauth_identities flag, set for every user at
upgrade time, so their first OAuth identity links without a provider
email verification claim. The flag is cleared once an identity links.

Also trust Microsoft Entra ID user principal names and GitLab confirmed
primary emails as verified, and pass the email to hasVerifiedEmail.
Add tests using real provider payloads.
2026-09-29 22:11:06 +02:00
Andras Bacsai df692e6278 fix(auth): honor instance registration for non-OIDC OAuth providers 2026-09-25 09:11:55 +02:00
Andras Bacsai c8dea4badc chore: align account lifecycle 2026-09-24 16:56:38 +02:00
Andras Bacsai 87685d1e09 chore: align control-plane behavior 2026-09-24 15:46:04 +02:00
Andras Bacsai 865ebe0bdd fix(auth): improve OAuth sign-in handling 2026-09-21 14:00:14 +02:00
Andras Bacsai ca5fcce39b Reapply "Merge branch 'next' into main"
This reverts commit 7bbd91175f.
2026-08-21 12:15:46 +02:00
Andras Bacsai 7bbd91175f Revert "Merge branch 'next' into main"
This reverts commit 2598f3e4c8, reversing
changes made to 83f1a2e503.
2026-08-21 12:12:56 +02:00
Andras Bacsai 81227670e6 Reapply "Merge origin/next into main"
This reverts commit 15359833d3.
2026-08-19 12:39:55 +02:00
Andras Bacsai 15359833d3 Revert "Merge origin/next into main"
This reverts commit 541d743907, reversing
changes made to bb1d3f13f2.
2026-08-19 12:33:16 +02:00
Andras Bacsai 3b08be1429 fix(auth): handle concurrent OAuth identity creation safely
Recover existing OAuth and OIDC identities after unique constraint races and reject boolean or floating-point provider IDs.
2026-08-18 15:43:46 +02:00
Andras Bacsai d29139f4a3 fix(auth): reject OAuth logins without valid provider IDs
Add validation for missing, blank, and non-scalar provider user IDs and cover the rejection cases with feature tests.
2026-08-18 15:34:37 +02:00
Andras Bacsai f9f26c547c fix(auth): preserve OAuth identity across email changes
Link OAuth logins by provider user ID before matching email, refresh identity
claims on login, and skip password confirmation for SSO-linked users.
2026-08-18 15:27:27 +02:00
Andras Bacsai 21333f02f9 fix(settings): harden OIDC, email, and log drain flows 2026-06-15 12:35:05 +02:00
Andras Bacsai e354840e5a feat(auth): add OIDC SSO and registration controls
Add OIDC discovery, JWKS validation, Socialite integration, OAuth identity linking, and configurable registration policy for password and SSO signups. Update related settings/profile UI and tests.
2026-06-04 13:59:08 +02:00
Andras Bacsai 07f381b88c Merge remote-tracking branch 'origin/next' into jean/port-exposes-improvement 2026-06-03 10:32:57 +02:00
Tristan Rhodes 519a186e84 fix: normalize oauth emails before matching users 2026-04-09 09:38:56 -06:00