- ABP Framework version: v9.0.3
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue: I'm having trouble getting my tenant domain resolver to work correctly. When I visit the tenant subdomain (e.g., http://tenant.mydomain:4200) and click the login button, I'm redirected to the correct authentication server URL with the tenant subdomain. However, I'm unable to log in as a tenant user.
I can log in as the host admin, but doing so signs me into the host account instead of the tenant account. I also noticed that when I first visit the tenant subdomain, abpSession in local storage contains tenant-related data, but this data is lost once I navigate to the authentication server. Additionally, I set breakpoints in my login component and found that ICurrentTenant is null.
Any ideas on what might be causing this issue?
AuthServerModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("Bookstore");
options.UseLocalServer();
options.UseAspNetCore();
});
});
if (!hostingEnvironment.IsDevelopment())
{
PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
{
options.AddDevelopmentEncryptionAndSigningCertificate = false;
});
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", configuration["AuthServer:CertificatePassPhrase"]!);
serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!));
});
}
PreConfigure<AbpOpenIddictWildcardDomainOptions>(options =>
{
options.EnableWildcardDomainSupport = true;
options.WildcardDomainsFormat.Add(configuration["WildcardDomains:API"]);
options.WildcardDomainsFormat.Add(configuration["WildcardDomains:Angular"]!);
options.WildcardDomainsFormat.Add(configuration["WildcardDomains:AuthServer"]);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<AbpTenantResolveOptions>(options =>
{
options.AddDomainTenantResolver(configuration["WildcardDomains:AuthServer"]!);
options.AddDomainTenantResolver(configuration["WildcardDomains:API"]!);
options.AddDomainTenantResolver(configuration["WildcardDomains:Angular"]!);
});
Configure<OpenIddictServerOptions>(options =>
{
options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator;
options.TokenValidationParameters.ValidIssuers = new[] { $"{configuration["WildcardDomains:AuthServer"]}/", $"{configuration["App:SelfUrl"]}/" };
});
HttpApiHostModule
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"] + "/" ;
options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata");
options.Audience = "Bookstore";
});
Configure<AbpTenantResolveOptions>(options =>
{
options.AddDomainTenantResolver(configuration["WildcardDomains:AuthServer"]);
options.AddDomainTenantResolver(configuration["WildcardDomains:Angular"]);
options.AddDomainTenantResolver(configuration["WildcardDomains:API"]);
});
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
});
}
3 Answer(s)
-
0
Hello,
We have sample projects for domain tenant resolver. You can compare your own application with the sample application and find out what the problem is.
Sample projects: https://github.com/abpframework/abp-samples/tree/master/DomainTenantResolver/OpenIddict
-
0
Hi, I have followed the examples; however there are none for ng tiered, so I have been trying to combine code from the MVC tiered and angular, but nothing has resolved the issue thus far.
-
0
Can you give me a little more detail about what errors you are getting so I can help you?