Aperto Chiuso

Subdomain Tenant URL change with Linked Accounts #7425


User avatar
0
dhill creato
  • ABP Framework version: v8.2.0
  • UI Type: Blazor Server
  • Database System: EF Core
  • **Azure Web App with AzureSignalR We've successfully implemented subdomain tenant mapping. However, when using linked accounts the subdomain does not change when the tenant change happens. How can we get the subdomain url to reflect the change in tentant?

Here is our WebModule configuration.

        PreConfigure<OpenIddictBuilder>(builder =>
        {
            _ = builder.AddValidation(options =>
            {
                _ = options.AddAudiences("SafetyPlusWeb");
                _ = options.UseLocalServer();
                _ = options.UseAspNetCore();
            });
        });

        if (!hostingEnvironment.IsDevelopment())
        {
            PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
            {
                options.AddDevelopmentEncryptionAndSigningCertificate = false;
            });

            PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
            {
                // In production, it is recommended to use two RSA certificates, 
                // one for encryption, one for signing.
                _ = serverBuilder.AddEncryptionCertificate(
                        GetEncryptionCertificate(context.Services.GetConfiguration()));
                _ = serverBuilder.AddSigningCertificate(
                        GetSigningCertificate(context.Services.GetConfiguration()));
            });

            var domainFormat = GetDomainFormatForEnvironment(hostingEnvironment);
            PreConfigure<AbpOpenIddictWildcardDomainOptions>(options =>
            {
                options.EnableWildcardDomainSupport = true;
                _ = options.WildcardDomainsFormat.Add($"https://{domainFormat}");
                _ = options.WildcardDomainsFormat.Add($"https://{domainFormat}/signin-oidc");
                _ = options.WildcardDomainsFormat.Add($"https://{domainFormat}/signout-callback-oidc");
            });
        }
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        var hostingEnvironment = context.Services.GetHostingEnvironment();
        var configuration = context.Services.GetConfiguration();

        var domainFormat = GetDomainFormatForEnvironment(hostingEnvironment);

        Configure<AbpTenantResolveOptions>(options =>
        {
            options.AddDomainTenantResolver(domainFormat);
        });

        if (!configuration.GetValue<bool>("App:DisablePII"))
        {
            Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
        }

        if (!configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"))
        {
            Configure<OpenIddictServerAspNetCoreOptions>(options =>
            {
                options.DisableTransportSecurityRequirement = true;
            });
        }

        if (!hostingEnvironment.IsDevelopment())
        {
            _ = context.Services.AddSignalR(options =>
            {
                options.AddFilter<AbpMultiTenantHubFilter>();
            }).AddAzureSignalR();
        }

        ConfigureOptions(context, configuration);
        ConfigureAuthentication(context);
        ConfigureUrls(configuration);
        ConfigureBundles();
        ConfigureImpersonation(context, configuration);
        ConfigureAutoMapper();
        ConfigureVirtualFileSystem(hostingEnvironment);
        ConfigureMultiTenancy();
        ConfigureSwaggerServices(context.Services);
        ConfigureExternalProviders(context, configuration);
        ConfigureAutoApiControllers();
        ConfigureBlazorise(context);
        ConfigureRouter(context);
        ConfigureMenu(context);
        ConfigureCookieConsent(context);
        ConfigureAuditingOptions(context);
        ConfigureTheme();

        Configure<SettingManagementComponentOptions>(options =>
        {
            options.Contributors.Add(new SafetyPlusWebSettingsComponentContributor());
        });

        if (!hostingEnvironment.IsDevelopment())
        {
            Configure<AbpTenantResolveOptions>(options =>
            {
                options.AddDomainTenantResolver(domainFormat);
            });
        }
    }
    ```

1 risposte
  • User Avatar
    0
    liangshiwei creato
    Team di supporto Fullstack Developer

    Hi,

    You can try

    Configure<AbpAccountOptions>(options =>
    {
        options.IsTenantMultiDomain = true;
        options.GetTenantDomain = (httpContext, info) => Task.FromResult(string.IsNullOrWhiteSpace(info.Name) ? $"https://getabp.net" : $"https://{info.Name}.getabp.net");
    });
    
Made with ❤️ on ABP v8.2.0-preview Updated on marzo 25, 2024, 15:11