Repository navigation
fix(security): logowanie Microsoft — weryfikacja tenanta, ostrzeżenie bpp.W201, ostrożniejsze wiązanie kont - #894
Merged
Merged
Conversation
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 38940246 | Triggered | Generic Password | ca40250 | src/bpp/tests/test_auth_microsoft.py | View secret |
| 38949182 | Triggered | Username Password | 4ce6391 | src/bpp/tests/test_auth_microsoft.py | View secret |
| 38940246 | Triggered | Generic Password | ca40250 | src/bpp/tests/test_auth_microsoft.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
…t Microsoft - logowanie Office 365 wymaga MICROSOFT_AUTH_TENANT_ID wskazującego konkretny katalog Entra ID (GUID lub domena); puste/common/organizations/consumers -> ImproperlyConfigured przy starcie, - nowy backend bpp.auth.microsoft.BppMicrosoftAuthenticationBackend (zamiast backendu z pakietu) sprawdza claimy iss/tid tokenu względem skonfigurowanego katalogu, - nowe konto Microsoft nie jest automatycznie wiązane po e-mailu z istniejącym kontem staff/superuser lub z hasłem lokalnym, chyba że MICROSOFT_AUTH_LINK_BY_EMAIL=True (domyślnie False); konta już powiązane logują się bez zmian, - dawna ścieżka backendu nadal rozpoznawana jako zewnętrzna (polityka haseł), - dokumentacja w docs/administrator/zaawansowane.md, testy, newsfragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ23Rb1c5UtxHTfAke9ENQ
…covery - nowe konto Microsoft bez (lub z pustym) adresem e-mail nie jest ani wiązane, ani zakładane, - wyszukanie istniejącego użytkownika bez rozróżniania wielkości liter; więcej niż jedno trafienie -> odmowa; backend nie deleguje już wiązania/zakładania do pakietu, - gdy zbuforowany dokument OpenID discovery nie odpowiada skonfigurowanemu katalogowi, cache jest jednorazowo odświeżany, - testy i doprecyzowana dokumentacja. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ23Rb1c5UtxHTfAke9ENQ
…ie błąd startu Pusty lub ogólny MICROSOFT_AUTH_TENANT_ID (common/organizations/consumers) nie blokuje już startu. Zamiast ImproperlyConfigured: system check bpp.W201 i komunikat dla superusera po zalogowaniu z podpowiedzią (GUID lub domena katalogu). Backend w trybie wielokatalogowym pomija weryfikację iss/tid, ale zachowuje ostrożne wiązanie kont. Przy konkretnym tenancie - pełna weryfikacja jak dotąd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ23Rb1c5UtxHTfAke9ENQ
…ązanych Bez konkretnego MICROSOFT_AUTH_TENANT_ID logują się wyłącznie konta Microsoft już powiązane z kontem BPP: bez zakładania nowych kont i bez wiązania po adresie e-mail (także dla kont bez uprawnień), z neutralnym komunikatem dla użytkownika. Jawny opt-in MICROSOFT_AUTH_MULTI_TENANT_ALLOW_LINKING=True przywraca ostrożne reguły wiązania. Treść bpp.W201 i komunikatu dla superusera opisuje ten tryb. Przy konkretnym tenancie zachowanie bez zmian. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ23Rb1c5UtxHTfAke9ENQ
mpasternak
force-pushed
the
sec/microsoft-tenant
branch
from
October 24, 2026 20:45
9af6e94 to
5503435
Compare
| assert wynik[0].id == W_TENANT_ID == "bpp.W201" | ||
| assert isinstance(wynik[0], checks.Warning) | ||
| assert "MICROSOFT_AUTH_TENANT_ID" in wynik[0].hint | ||
| assert "onmicrosoft.com" in wynik[0].hint |
| ) | ||
| komunikaty = _komunikaty(_zaloguj(client, "szef")) | ||
| assert any( | ||
| OSTRZEZENIE in m and "onmicrosoft.com" in m and "są wyłączone" in m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Co zmieniono
Hardening opcjonalnego logowania Office 365 (
django-microsoft-auth, extraoffice365):src/django_bpp/settings/base.py,src/bpp/auth/microsoft_conf.py): pustyMICROSOFT_AUTH_TENANT_IDjest normalizowany docommon. Gdy ustawionoMICROSOFT_AUTH_CLIENT_ID, a tenant jest pusty albo równycommon/organizations/consumers:bpp.W201(Warning,src/bpp/checks.py) z podpowiedzią: GUID katalogu albo domenauczelnia.onmicrosoft.com;messages.warningdla superusera po zalogowaniu (handleruser_logged_in,dispatch_uid="bpp.ostrzez_superusera_o_tenancie_microsoft",src/bpp/apps.py); błędy są logowane i nie blokują logowania.bpp.auth.microsoft.BppMicrosoftAuthenticationBackend(zastępuje wAUTHENTICATION_BACKENDSbackend z pakietu):isstokenu względemissuerz discovery skonfigurowanego katalogu oraztid(dla GUID-a również bezpośrednio); token odrzucany jest, zanim powstanie rekordMicrosoftAccount. Gdy zbuforowany dokument discovery nie pasuje do katalogu, cache jest jednorazowo odświeżany;iss/tidjest pomijana, bo nie ma katalogu, względem którego można ją zrobić. Logują się wyłącznie konta Microsoft już powiązane z kontem BPP. Nowe konta nie są zakładane (niezależnie odMICROSOFT_AUTH_AUTO_CREATE) ani wiązane po e-mailu. Użytkownik dostaje neutralny komunikat „Konto Microsoft nie jest powiązane z kontem w BPP — skontaktuj się z administratorem”. Jawny opt-inMICROSOFT_AUTH_MULTI_TENANT_ALLOW_LINKING=True(nowy env, domyślnieFalse) włącza w tym trybie reguły opisane niżej;email__iexact; więcej niż jedno trafienie → odmowa; istniejące kontois_staff/is_superuseralbo z hasłem lokalnym nie jest automatycznie wiązane, chyba żeMICROSOFT_AUTH_LINK_BY_EMAIL=True(nowy env, domyślnieFalse);src/django_bpp/external_auth.py,src/django_bpp/views.py: nowa ścieżka backendu wEXTERNAL_AUTH_BACKENDS; dawna jest nadal rozpoznawana.docs/administrator/zaawansowane.md, sekcja „Logowanie przez Microsoft”: zalecenie ustawienia tenanta, skutki jego braku i opt-in.Wpływ na wdrożenia
commondaje tylko ostrzeżeniebpp.W201i komunikat dla superusera.MICROSOFT_AUTH_TENANT_ID(zalecane) albo świadomieMICROSOFT_AUTH_MULTI_TENANT_ALLOW_LINKING=True. Konto można też powiązać ręcznie w adminie (Microsoft accounts).MICROSOFT_AUTH_LINK_BY_EMAIL=True.Testy
src/bpp/tests/test_auth_microsoft.py:bpp.W201(puste,common,organizations,consumers, GUID, domena, opt-in) i komunikat po prawdziwym POST na/admin/login/(superuser go dostaje, zwykły staff nie, przy GUID-zie nikt, wyjątek w handlerze nie blokuje logowania) — bez markera, biegną w CI;uruchom_tylko_z_microsoft_auth, więc w CI są pomijane. Obejmują konkretny tenant oraz tryb wielokatalogowy: powiązane konto się loguje; niepowiązane jest odrzucane, nie powstaje nowy użytkownik ani wiązanie po e-mailu, także dla kont bez uprawnień; z opt-in obowiązują ostrożne reguły. Lokalnie uruchamiasz je tak:Wyniki lokalne (
test_auth_microsoft.py+test_konta_bez_uczelni.py):common: 74 passed;Pokrewne moduły (checks, szyfrowanie sekretów, auth_server, password middleware, context processor, smart password change): 67 passed bez microsoft_auth i 67 passed z
common.🤖 Generated with Claude Code
https://claude.ai/code/session_01UJ23Rb1c5UtxHTfAke9ENQ