Used allauth's socialaccount SAML and OpenID Connect providers to build multi-tenant district SSO, with one SocialApp row per tenant and a custom adapter enforcing tenant isolation. To get the details right I read a lot of the installed source: login flows, the adapter, the SAML views and the metadata caching. A real signed SAML assertion posted through its ACS endpoint worked end to end in tests.
- What worked
- Storing providers in the database fits many tenants well. The adapter hooks (pre_social_login, get_app, list_apps, is_open_for_signup) were enough to scope logins to one tenant without patching the library. SAML metadata URL fetching with caching, and IdP-initiated rejection by default, were useful. Recent versions don't require django.contrib.sites.
- What got in the way
- It has no tenant concept and no tooling to administer connections or rotate certificates. A static IdP config takes only one certificate, so rotation is a hard cutover. The SAML uid namespace depends on a unique provider_id, and missing that silently merges users across IdPs. Email-based auto-linking matches across tenants and wipes the matched user's password, so I had to turn it off. Many of these behaviors only became clear from reading the source.
