diff --git a/docs/en/Multi-Tenancy.md b/docs/en/Multi-Tenancy.md index 19cf8fa443..661d99da16 100644 --- a/docs/en/Multi-Tenancy.md +++ b/docs/en/Multi-Tenancy.md @@ -273,7 +273,7 @@ Configure(options => ##### Domain/Subdomain Tenant Resolver -In a real application, most of times you will want to determine current tenant either by subdomain (like mytenant1.mydomain.com) or by the whole domain (like mytenant.com). If so, you can configure the `AbpTenantResolveOptions` to add the domain tenant resolver. +In a real application, most of times you will want to determine the current tenant either by subdomain (like mytenant1.mydomain.com) or by the whole domain (like mytenant.com). If so, you can configure the `AbpTenantResolveOptions` to add the domain tenant resolver. **Example: Add a subdomain resolver** @@ -284,11 +284,65 @@ Configure(options => }); ```` -* `{0}` is the placeholder to determine current tenant's unique name. +* `{0}` is the placeholder to determine the current tenant's unique name. * Add this code to the `ConfigureServices` method of your [module](Module-Development-Basics.md). * This should be done in the *Web/API Layer* since the URL is a web related stuff. -> There is an [example](https://github.com/abpframework/abp-samples/tree/master/DomainTenantResolver) that uses the subdomain to determining the current tenant. +Openiddict is the default Auth Server in ABP (since v6.0). When you use OpenIddict, you must add this code to the `PreConfigure` method as well. + +```csharp +// using Volo.Abp.OpenIddict.WildcardDomains + +PreConfigure(options => +{ + options.EnableWildcardDomainSupport = true; + options.WildcardDomainsFormat.Add("https://{0}.mydomain.com"); +}); +``` + +You must add this code to the `Configure` method as well. + +```csharp +// using Volo.Abp.MultiTenancy; + +Configure(options => +{ + options.AddDomainTenantResolver("{0}.mydomain.com"); +}); + +``` + +> There is an [example](https://github.com/abpframework/abp-samples/tree/master/DomainTenantResolver) that uses the subdomain to determine the current tenant. + +If you use a sepereted Auth server, you must install `[Owl.TokenWildcardIssuerValidator](https://www.nuget.org/packages/Owl.TokenWildcardIssuerValidator)` on the `HTTPApi.Host` project + +```bash +dotnet add package Owl.TokenWildcardIssuerValidator +``` + +Then fix the options of the `.AddJwtBearer` block + +```csharp +// using using Owl.TokenWildcardIssuerValidator; + +context.Services + .AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "ExampleProjectName"; + + // start of added block + options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator; + options.TokenValidationParameters.ValidIssuers = new[] + { + "https://{0}.mydomain.com:44349/" //the port may different + }; + // end of added block + }); + +``` ##### Custom Tenant Resolvers