mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
[PR #1142] [MERGED] fix(oidc): Allow auto_link_existing_accounts with custom email claims (Azure Entra ID) #1164
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy#1164
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/maziggy/bambuddy/pull/1142
Author: @netscout2001
Created: 4/27/2026
Status: ✅ Merged
Merged: 4/28/2026
Merged by: @maziggy
Base:
dev← Head:fix/oidc-allow-auto-link-with-custom-claim📝 Commits (10+)
50f482cchore(i18n): extend parity gate to all locales with strict/info tiersce88bd6Bumped version339cd40Added new update.sh and update docseff65bafix(oidc): allow auto_link_existing_accounts with custom email claims585eb47fix(oidc): prevent require_email_verified toggle from jumping layout606f9eaMerge branch 'dev' into fix/oidc-allow-auto-link-with-custom-claimd8d733bMerge branch 'dev' into fix/oidc-allow-auto-link-with-custom-claim21a3200fix(oidc): address PR #1142 review feedback86715baMerge branch 'dev' into fix/oidc-allow-auto-link-with-custom-claim65a26fdMerge branch 'dev' into fix/oidc-allow-auto-link-with-custom-claim📊 Changes
19 files changed (+628 additions, -87 deletions)
View changed files
📝
CHANGELOG.md(+2 -0)📝
UPDATING.md(+10 -9)📝
backend/app/api/routes/mfa.py(+6 -7)📝
backend/app/core/database.py(+104 -11)📝
backend/app/models/oidc_provider.py(+4 -4)📝
backend/app/schemas/auth.py(+12 -9)📝
backend/tests/integration/test_mfa_api.py(+213 -13)📝
backend/tests/unit/test_db_dialect.py(+235 -17)📝
frontend/scripts/check-i18n-parity.mjs(+1 -14)📝
frontend/src/__tests__/components/OIDCProviderSettings.test.tsx(+28 -1)📝
frontend/src/components/OIDCProviderSettings.tsx(+5 -2)📝
frontend/src/i18n/locales/de.ts(+1 -0)📝
frontend/src/i18n/locales/en.ts(+1 -0)📝
frontend/src/i18n/locales/fr.ts(+1 -0)📝
frontend/src/i18n/locales/it.ts(+1 -0)📝
frontend/src/i18n/locales/ja.ts(+1 -0)📝
frontend/src/i18n/locales/pt-BR.ts(+1 -0)📝
frontend/src/i18n/locales/zh-CN.ts(+1 -0)📝
frontend/src/i18n/locales/zh-TW.ts(+1 -0)📄 Description
Description
Relaxes the SEC-1 guard for
auto_link_existing_accountsso that providers using a customemail_claim(e.g.preferred_username,upn) — the recommended Azure Entra ID configuration — can safely enable automatic account linking.Previously the guard blocked all combinations except
email_claim='email'+require_email_verified=True. This also blocked Azure Entra ID configurations that use a custom claim, even though those are not subject to the email-verification bypass attack.The new guard only blocks the genuinely unsafe combination (Fall B):
email_claim='email'+require_email_verified=False. Custom-claim paths (Fall C) never perform anemail_verifiedcheck, so an attacker-controlled IdP cannot exploit email matching — auto-linking is safe there.Docs ->
Related Issue
Fixes maziggy/bambuddy#1088
Documentation
Type of Change
Changes Made
models/oidc_provider.py: UpdatedCheckConstraintformula fromrequire_email_verified = TRUE AND email_claim = 'email'toemail_claim != 'email' OR require_email_verified = TRUE(only blocks Fall B)schemas/auth.py: UpdatedOIDCProviderCreateandOIDCProviderUpdatemodel validators and error message to match the new guard conditionapi/routes/mfa.py: Updated_enforce_auto_link_safety()combined-state guard to the same Fall-B-only conditioncore/database.py: Added_migrate_update_auto_link_constraint()to update the DB constraint on existing installations — SQLite via table recreation (shadow table pattern), PostgreSQL viaDROP CONSTRAINT IF EXISTS+ADD CONSTRAINT; narrowed backfill SQL to only reset unsafe Fall B rowstests/integration/test_mfa_api.py: Updated 4 tests and added 2 new tests covering the newly allowed Fall C scenarios and continued blocking of Fall Btests/unit/test_db_dialect.py: Updated 2 unit tests and added 4 new tests for the new constraint formula and the SQLite migration functionTesting
163 relevant tests pass (
tests/integration/test_mfa_api.py+tests/unit/test_db_dialect.py). Full test suite: no regressions.Key scenarios verified:
emailTrueTrueemailFalseTruepreferred_usernameTrueupnFalseTrueAdditional Notes
Migration behavior:
CHECKconstraint is applied at schema creation time — no action needed._migrate_update_auto_link_constraint()recreates theoidc_providerstable with the new constraint (SQLite does not supportALTER TABLE DROP/ADD CONSTRAINT). The old constraint is detected viasqlite_master; the migration is a no-op if already on the new formula.DROP CONSTRAINT IF EXISTS+ADD CONSTRAINT— fully idempotent.email_claim='email'+require_email_verified=False+auto_link=True) are reset by the backfill; Fall C rows are left unchanged.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.