# TraconTenancyOptions

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.tracontenancyoptions/
> Summary: TraconTenancyOptions: Settings that determine how the tenant is resolved from the request.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.AspNetCore.dll</code></div>

Settings that determine how the tenant is resolved from the request.

```csharp
public sealed class TraconTenancyOptions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.tracontenancyoptions/">TraconTenancyOptions</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

**Off by default.** A single-tenant setup needs no extra
configuration, and every request falls to the
[TraconOptions.DefaultTenantId](/api/tracon.traconoptions/#Tracon_TraconOptions_DefaultTenantId) tenant.

**A header can be spoofed.** An HTTP header is not proof of
identity; the client can write any value it wants. Therefore:

- If [TraconTenancyOptions.ClaimType](/api/tracon.tracontenancyoptions/#Tracon_TraconTenancyOptions_ClaimType) is set and the request passed authentication, **only the claim** is used; the header is ignored.
- The header path must be explicitly opened via [TraconTenancyOptions.AllowHeaderResolution](/api/tracon.tracontenancyoptions/#Tracon_TraconTenancyOptions_AllowHeaderResolution) and used only inside a trusted network (or only during development).
- If [TraconTenancyOptions.AllowedTenants](/api/tracon.tracontenancyoptions/#Tracon_TraconTenancyOptions_AllowedTenants) is non-empty, an unresolved tenant is rejected; a value not in the list does *not* fall back to the default tenant.

This type is deliberately not a `record`; settings classes' generated
`ToString` method could leak values.

## Constructors

### <a id="Tracon_TraconTenancyOptions__ctor"></a> TraconTenancyOptions\(\)

```csharp
public TraconTenancyOptions()
```

## Properties

### <a id="Tracon_TraconTenancyOptions_AllowHeaderResolution"></a> AllowHeaderResolution

Whether the tenant can be resolved from the header. **Off by default**
— a header can be spoofed.

```csharp
public bool AllowHeaderResolution { get; set; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_TraconTenancyOptions_AllowedTenants"></a> AllowedTenants

The accepted tenant ids. If left empty, any value matching the format is accepted.

```csharp
public IList<string> AllowedTenants { get; }
```

#### Property Value

 [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\>

#### Remarks

**The format** is `^[a-zA-Z0-9_.-]+$`, at most 64
characters. A value that does not match is never resolved.

**Letter case does not distinguish two tenants.** Entries
and incoming values are both folded with
[AmbientTenantScope.Normalize](/api/tracon.ambienttenantscope/#Tracon_AmbientTenantScope_Normalize_System_String_) before they are compared, so
`Acme` here admits a request that arrives as `acme`, and the
reverse. The same fold is what every store persists, so one tenant can
never split into two rows because someone typed a capital letter.

### <a id="Tracon_TraconTenancyOptions_ClaimType"></a> ClaimType

The claim type the tenant is read from. Example: `tenant_id`.
If set and the request passed authentication, it takes precedence over the header.

```csharp
public string? ClaimType { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_TraconTenancyOptions_Enabled"></a> Enabled

Whether multi-tenancy is enabled. When disabled, every request falls to the
default tenant.

```csharp
public bool Enabled { get; set; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_TraconTenancyOptions_HeaderName"></a> HeaderName

The HTTP header the tenant is read from.

```csharp
public string HeaderName { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)
