Add IdentityServerTenantResolveContributor
class to your project.
public class IdentityServerTenantResolveContributor : HttpTenantResolveContributorBase
{
public override string Name => "IdentityServer";
protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context,
HttpContext httpContext)
{
if (httpContext.Request.Path == "/Account/Login" && httpContext.Request.Query.ContainsKey("ReturnUrl"))
{
var interaction = httpContext.RequestServices.GetService<IIdentityServerInteractionService>();
var authorizationContext = AsyncHelper.RunSync(() =>
interaction.GetAuthorizationContextAsync(httpContext.Request.Query["ReturnUrl"]));
if (context != null)
{
//TODO: Reference AspNetCore MultiTenancy module and use options to get the tenant key!
var tenantIdOrName = authorizationContext.Parameters[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey];
return tenantIdOrName;
}
}
return null;
}
}
Then configure AbpTenantResolveOptions
options to add IdentityServerTenantResolveContributor
in AuthServerHostModule
.
Configure<AbpTenantResolveOptions>(opt =>
{
opt.TenantResolvers.Add(new IdentityServerTenantResolveContributor());
});
Hi,
Display problem only,You can continue to login as a tenant users.
You can use EF Core reverse engineering to generate code, see https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli
if you want to take the advantage of the new ABP Framework features and the new architecture opportunities (like support for NoSQL databases, microservice compatibility, advanced modularity), you can starting with commercial.abp.io.
Hi
Please refer https://docs.abp.io/en/commercial/latest/ui/aspnetcore/entity-action-extensions
Hi PR has been merged.
I added AbpApplicationPathViewComponent used to set abp.appPath value, but it is not added to the startup template by default. For developers who deploy using virtual paths, please add the following code to your module:
Configure<AbpLayoutHookOptions>(options =>
{
options.Add(LayoutHooks.Head.Last,
typeof(AbpApplicationPathViewComponent));
});
Hi,
I can't reproduce this problem,no need to refresh again. You need to remove the DomainTenantResolveContributor
in authserver.
Hi,
This seems to be a browser limitation,for 302 redirect, when the browser sends the request again, the host in the request header is not the current website. So, can't use subdomain determine current tenant.
We can add the current tenant to the querystring when redirecting, like this:
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(365);
})
.AddOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.RequireHttpsMetadata = false;
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role");
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("BackendAdminAppGateway");
options.Scope.Add("IdentityService");
options.Scope.Add("ProductService");
options.Scope.Add("TenantManagementService");
options.ClaimActions.MapAbpClaimTypes();
// Add the following code
options.Events.OnRedirectToIdentityProvider = redirectContext =>
{
var currentTenant = redirectContext.HttpContext.RequestServices.GetService<ICurrentTenant>();
if (currentTenant.Id.HasValue)
{
var multiTenancyOptions = redirectContext.HttpContext.RequestServices.GetService<IOptions<AbpAspNetCoreMultiTenancyOptions>>().Value;
redirectContext.ProtocolMessage.IssuerAddress += $"?{multiTenancyOptions.TenantKey}="+currentTenant.Id.Value;
}
return Task.CompletedTask;
};
});
I will check it out.
About redis error, please see https://stackoverflow.com/questions/35614066/redissessionstateprovider-err-unknown-command-eval
Hi,
Currently will not create a database after creating a tenant, you need run .DbMigrator
project to create tenant database.