Is it possible to use Squidex Identity to connect to more than one app?
Now it is not possible since the configuration is in the appsetting.json
would like to inject this configuration or load it base on the URL.
thank you.
Is it possible to use Squidex Identity to connect to more than one app?
Now it is not possible since the configuration is in the appsetting.json
would like to inject this configuration or load it base on the URL.
thank you.
What behavior do you expect?
I would like to add multitenancy where each app in squidex is a tenant and the url will be use to differentiate the current tenant.
RIght now it is not possible but if you want to help, I would migrate it to .NET Core 3.1. Some classes like UserManager have to be registered with a scoped lifetime anyway and then you could write a factory that is registered as singleton and holds multiple client manager instances.
Are you able to provide a snippet of what to be modified?
thanks in advance.
We have a few services likes this one, that get a squidex client manager:
Instead of injection the client manager we need an indirection, e.g.
class ClientManagerProvider {
private IHttpContextAccessor httpContextAccesor;
private ConcurrentDictionary<string, SquidexClientManager> clientManagerPerDomain;
private Dictionary<string, SquidexOptions> optionsPerDomain;
public SquidexClientManager GetClientManager()
{
var host = httpContextAccessor.HttpContext.Request.Host;
if (!optionsPerDomain.TryGetValue(host, out var options))
{
throw new InvalidOperationException("Invalid host.");
}
return clientManagerPerDomain.GetOrAdd(host, x => new SquidexClientManager(options));
}
}
Then you can either inject this provider to the services and create the clients on the fly (they are lightweight)
OR
When the services are registered as a scope we can just replace this line with something like
services.AddSingleton<ClientManagerProvider>();
services.AddSingleton<SquidexClientManager>(c => c.GetRequiredService<ClientManagerProvider>().GetClientManager());
When looking how the services are registered, the second approach should work fine:
e.g.
OR
I have started to convert it. It is pushed, but really untested so far.