Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tbhaxor's avatar

Software design for dynamic identity provider

I have a multi-tenancy application where I will be having atleast 3 tables

  • organizations
    • id
    • domain
    • owner_id (fk to users)
  • users
    • id
    • email
    • organization_id (fk to organizations)
  • identity_providers
    • config (arrayable field)
    • organization_id (fk to organizations)
    • type (openid or saml2)

I want to allow organization owners to configure saml2 identity provider and on the login page I want to check domain from email, get organization, get identity provider, configure socialite with identity_providers.type and redirect it.

Please not there is only one authentication endpoint where I want to support multiple organization idp.

Of course if the idp is not configured, it will ask for the password in the step 2.

I want to ask, if I set config dynamically in a middleware, will it work for concurrent requests?

 // Get organization and idp details here
config(['services.saml2' => [
// Add saml2 configuration here
]]);
0 likes
4 replies
tbhaxor's avatar

@Tray2 Yes, I want to use socialite but that takes the config from services.[driver]. So if I have set it in a middleware wouldnt that reflect application wide (for all the requests)?

PS: I am coming from python and nodejs background.

tbhaxor's avatar

I have tried this and it worked for me. Thanks

Please or to participate in this conversation.