Open Closed

Subdomain Tenant URL change with Linked Accounts #7425


User avatar
0
dhill created
  • 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);
            });
        }
    }
    ```

8 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team 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");
    });
    
  • User Avatar
    0
    alper created
    Support Team Director

    hi we reopened this ticket per your request

  • User Avatar
    0
    dhill created

    Hi,

    I tried adding that code but it didn't actually refresh the url in the browser.

    Is this something that has to happen on the client wasm side with blazor full stack?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Add to your auth server project

    Configure<AbpAccountOptions>(options =>
    {
        options.IsTenantMultiDomain = true;
        options.GetTenantDomain = (httpContext, info) => Task.FromResult(string.IsNullOrWhiteSpace(info.Name) ? $"https://getabp.net" : $"https://{info.Name}.getabp.net");
    });
    
  • User Avatar
    0
    dhill created

    We don't have an auth server project. Only the Blazor and Blazor.Client projects.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    okay, add to Blazor project

    if still not work, please let me know, i will check it.

  • User Avatar
    0
    dhill created

    Looks like that worked :)

    We need to do a bit more integration testing to know for sure though.

  • User Avatar
    0
    dhill created

    This looks like it's working correctly now. Thanks!

Made with ❤️ on ABP v9.1.0-preview. Updated on November 18, 2024, 05:54