mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
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#1166
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/1176
Author: @netscout2001
Created: 4/30/2026
Status: ✅ Merged
Merged: 5/2/2026
Merged by: @maziggy
Base:
dev← Head:fix/oidc-autocreate-username-readable-claim📝 Commits (7)
c09f4a2fix(oidc): use preferred_username/name claim for auto-created usernamefc7ec64Merge branch 'dev' into fix/oidc-autocreate-username-readable-claim85ffc45Merge remote-tracking branch 'upstream/dev' into fix/oidc-autocreate-username-readable-claimf5560d0feat(oidc): configurable default group for auto-created users7ec80c2Merge remote-tracking branch 'origin/fix/oidc-autocreate-username-readable-claim' into fix/oidc-autocreate-username-readable-claime8cd605docs: add CHANGELOG entry for OIDC username derivation and default groupd949d52Merge branch 'dev' into fix/oidc-autocreate-username-readable-claim📊 Changes
17 files changed (+807 additions, -10 deletions)
View changed files
📝
CHANGELOG.md(+2 -0)📝
backend/app/api/routes/mfa.py(+47 -9)📝
backend/app/core/database.py(+8 -0)📝
backend/app/models/oidc_provider.py(+6 -0)📝
backend/app/schemas/auth.py(+3 -0)📝
backend/tests/integration/test_mfa_api.py(+603 -0)📝
frontend/src/__tests__/components/OIDCProviderSettings.test.tsx(+77 -0)📝
frontend/src/api/client.ts(+2 -0)📝
frontend/src/components/OIDCProviderSettings.tsx(+35 -1)📝
frontend/src/i18n/locales/de.ts(+3 -0)📝
frontend/src/i18n/locales/en.ts(+3 -0)📝
frontend/src/i18n/locales/fr.ts(+3 -0)📝
frontend/src/i18n/locales/it.ts(+3 -0)📝
frontend/src/i18n/locales/ja.ts(+3 -0)📝
frontend/src/i18n/locales/pt-BR.ts(+3 -0)📝
frontend/src/i18n/locales/zh-CN.ts(+3 -0)📝
frontend/src/i18n/locales/zh-TW.ts(+3 -0)📄 Description
Description
Addresses two issues from #1173:
Thread 1 — Readable usernames for OIDC auto-created users
When OIDC auto-creates a new user and no valid email claim is present (e.g. Fall C with a custom
email_claim), the username was derived from the opaqueprovider_sub[:30]— producing unreadable usernames like2f8a91bc04d7e3c0a512. This PR fixes the derivation chain to prefer human-readable IdP claims.New derivation order (no email available):
preferred_usernameclaim → sanitizednameclaim → sanitized (fallback ifpreferred_usernameis absent or sanitizes to empty)provider_sub[:30]→ sanitized (last resort)isinstanceguards protect against non-string claim values (e.g. a list), and sanitization is applied per candidate so that a value that strips to empty (e.g."!!!") correctly falls through to the next option instead of silently producing"oidcuser".Thread 2 — Configurable default group for OIDC auto-created users
Each OIDC provider gains a
default_group_idfield. When set, auto-created users are placed in that group instead of always landing in Viewers. The resolution chain is: configured group → Viewers fallback → no group.Details:
oidc_providerswithON DELETE SET NULL; migration ordered after_migrate_update_auto_link_constraintto survive the SQLite table-recreation that function performs on stale-formula databasesNonefalls through to Viewers, keeping the flow safe if the configured group is later deleteddefaultGroup,defaultGroupDesc,defaultGroupViewersFallback) in all 8 localesLimitation: to clear a configured default group, delete the group or select a different one — explicit reset-to-null is not currently supported (consistent with how
icon_urland other nullable fields behave).Thread 3 — Email-gating in UsersPage edit modal
Neither the maintainer nor the contributor can reproduce this on current
dev. The UsersPage edit modal disables password-reset/email controls but not groups or permissions, and email is optional in the schema. Dropped from this PR's scope — reduced to "needs reporter repro" in #1173 for a separate follow-up if concrete steps surface.Related Issue
Fixes #1173 (Threads 1 & 2)
Documentation
default_group_idfield on OIDC provider (form dropdown + CHANGELOG entry added)Type of Change
Changes Made
Thread 1
backend/app/api/routes/mfa.py: extend username derivation in the auto-create block (preferred_username→name→provider_sub) with per-candidate sanitization andisinstanceguardsbackend/tests/integration/test_mfa_api.py: addTestOIDCAutoCreateUsernamewith 7 integration testsThread 2
backend/app/models/oidc_provider.py: nullabledefault_group_idFK columnbackend/app/schemas/auth.py:default_group_idonOIDCProviderCreate,OIDCProviderUpdate,OIDCProviderResponsebackend/app/core/database.py: idempotentALTER TABLEmigrationbackend/app/api/routes/mfa.py: FK validation on create/update; resolution chain in auto-create blockfrontend/src/api/client.ts:default_group_idonOIDCProviderandOIDCProviderCreatetypesfrontend/src/components/OIDCProviderSettings.tsx: group dropdown + detail viewfrontend/src/i18n/locales/*.ts: 3 new keys in all 8 localesbackend/tests/integration/test_mfa_api.py: 5 newTestOIDCProviderscases +TestOIDCAutoCreateDefaultGroupwith 4 casesfrontend/src/__tests__/components/OIDCProviderSettings.test.tsx: 6 new testsCHANGELOG.md: entry for both improvements including limitation noteScreenshots
N/A — backend-only for Thread 1; Thread 2 adds a group dropdown to the existing OIDC provider form (admin-only settings page)
Testing
Thread 1 — 7 integration tests in
TestOIDCAutoCreateUsername:test_preferred_username_used_when_no_emailpreferred_username='johndoe'johndoetest_preferred_username_spaces_sanitizedpreferred_username='John Doe'JohnDoetest_name_claim_used_when_no_preferred_usernamename='Jane Smith'JaneSmithtest_provider_sub_fallback_when_no_claimsabc123xyztest_non_string_preferred_username_falls_through_to_namepreferred_username=["listval"],name='BobJones'BobJonestest_preferred_username_sanitizes_to_empty_falls_through_to_namepreferred_username='!!!',name='bob'bobtest_username_collision_appends_countercolliderusercollider1Thread 2 — 9 backend + 6 frontend tests:
test_create_provider_with_default_group_idtest_create_provider_invalid_default_group_id_returns_422test_create_provider_omit_default_group_id_stores_nullnulltest_update_provider_default_group_idtest_default_group_id_in_public_and_admin_listtest_configured_group_assigned_to_auto_created_usertest_null_default_group_id_falls_back_to_viewersnull→ Viewers fallbacktest_dangling_default_group_id_falls_back_to_viewerstest_administrators_group_can_be_set_as_defaultChecklist
Additional Notes
Thread 1 fix is limited to the auto-create path (
provider.auto_create_users = True). The auto-link path (matching existing users byprovider_subor email) is unaffected.Thread 2:
default_group_idfollows the existingexclude_none=TruePATCH semantics — a PATCH that omits the field leaves the current value unchanged. This is consistent withicon_urland the other nullable provider fields.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.