title: AWS Cognito user pools on multi-tenant web app
body: <p>We have a single .net Core MVC web application which will be used by multiple customers. Each customer will have a number of users.</p>
  
  <p>We intend to use AWS Cognito for user authentication and reading up on this I see that a user pool per customer is one of the recommended routes. This works well for our use-case as customer A might want a user with the username "Bob" and customer B might want another user with the username "Bob".</p>
  
  <p>Everything I have read suggests this should be possible but here is the issue:</p>
  
  <p>In .net core I have to specify some details that are specific to a particular app pool on startup:</p>
  
  <pre><code>                .AddOpenIdConnect(async options =&gt;
              {
                  options.ResponseType = OpenIdConnectResponseType.Code;
  
                  options.ConfigurationManager = new ConfigurationManager&lt;OpenIdConnectConfiguration&gt;(
                                                  services.BuildServiceProvider().GetService&lt;IOpenIdDiscovery&gt;().OpenIdConfigurationUrl(),
                                                  new OpenIdConnectConfigurationRetriever(),
                                                  services.BuildServiceProvider().GetService&lt;System.Net.Http.HttpClient&gt;());
  
                  options.Authority = Configuration["OpenIdAuthority"];
                  options.ClientId = Configuration["AuthCodeClientId"];
                  options.ClientSecret = Configuration["AuthCodeClientSecret"];
  </code></pre>
  
  <p>How do I go about getting the application to use multipleuser pools?</p>
  
  <p>To elaborate on the above I suppose the ideal solution would be: </p>
  
  <p>1) We direct the user to a specific login URL for their user pool. 
  2) After login user gets redirected to the central site.
  3) We somehow detect which user pool they authenticated through and set ClientId and ClientSecret accordingly for the session.</p>