Class TenancyOptionsExtensions

Namespace
Cratis.Arc.Tenancy
Assembly
Cratis.Arc.Core.dll

Extension methods for configuring tenancy in Arc.

public static class TenancyOptionsExtensions
Inheritance
TenancyOptionsExtensions
Inherited Members

Methods

UseClaimTenancy(ArcOptions, string?)

Configure tenancy to use claims for resolving tenant IDs.

public static ArcOptions UseClaimTenancy(this ArcOptions options, string? claimType = null)

Parameters

options ArcOptions

The ArcOptions to configure.

claimType string

Optional claim type to use. Defaults to 'tenant_id'.

Returns

ArcOptions

The ArcOptions for continuation.

UseDevelopmentTenancy(ArcOptions, string?)

Configure tenancy to use a fixed tenant ID for development purposes.

public static ArcOptions UseDevelopmentTenancy(this ArcOptions options, string? tenantId = null)

Parameters

options ArcOptions

The ArcOptions to configure.

tenantId string

Optional tenant ID to use. Defaults to 'development'.

Returns

ArcOptions

The ArcOptions for continuation.

UseFixedTenancy(ArcOptions, string?)

Configure tenancy to resolve every request to one fixed tenant ID.

public static ArcOptions UseFixedTenancy(this ArcOptions options, string? tenantId = null)

Parameters

options ArcOptions

The ArcOptions to configure.

tenantId string

Optional tenant ID to use. Defaults to 'development'.

Returns

ArcOptions

The ArcOptions for continuation.

Remarks

The tenant ID is returned regardless of the request or the hosting environment, which makes this the resolver for single tenant deployments. It is the same behavior as UseDevelopmentTenancy(ArcOptions, string?) under a name that does not imply an environment - the tenant ID both configure is the same value.

UseHeaderTenancy(ArcOptions, string?)

Configure tenancy to use HTTP headers for resolving tenant IDs.

public static ArcOptions UseHeaderTenancy(this ArcOptions options, string? headerName = null)

Parameters

options ArcOptions

The ArcOptions to configure.

headerName string

Optional header name to use. Defaults to 'x-cratis-tenant-id'.

Returns

ArcOptions

The ArcOptions for continuation.

UseQueryTenancy(ArcOptions, string?)

Configure tenancy to use query string parameters for resolving tenant IDs.

public static ArcOptions UseQueryTenancy(this ArcOptions options, string? queryParameter = null)

Parameters

options ArcOptions

The ArcOptions to configure.

queryParameter string

Optional query parameter name to use. Defaults to 'tenantId'.

Returns

ArcOptions

The ArcOptions for continuation.

UseSubdomainTenancy(ArcOptions, string, string?)

Configure tenancy to resolve the tenant ID from the request subdomain of a base domain, with the HTTP header as fallback.

public static ArcOptions UseSubdomainTenancy(this ArcOptions options, string baseDomain, string? fallbackHeaderName = null)

Parameters

options ArcOptions

The ArcOptions to configure.

baseDomain string

The base domain the application is served from, for instance 'myapp.com'.

fallbackHeaderName string

Optional header name used as fallback. Defaults to 'x-cratis-tenant-id'.

Returns

ArcOptions

The ArcOptions for continuation.

Remarks

A host resolves a tenant only when it is exactly one label in front of baseDomain - acme.myapp.com resolves acme for the base domain myapp.com. The base domain itself, a deeper host, an IP literal and any other host fall back to fallbackHeaderName. The base domain is required, and must be the registrable domain the application is served from - a bare top level domain such as com would make every host on the internet a tenant.

Exceptions

BaseDomainIsNotADomainName

Thrown when baseDomain is not a domain name tenants can be resolved in front of.