Orleans.Lattice.Auth
This page documents Orleans.Lattice.Auth 10.5.0, in the documentation for Orleans.Lattice 10.5.0 (release line 10.5), built 2026-12-05. It is also published as markdown, with every table and list, at README.md, and llms.txt lists every page.Authorization and enforcement add-on for Orleans.Lattice.
What is it?
Orleans.Lattice.Auth is the authorization layer of a lattice cluster. It builds on the subjects that Orleans.Lattice.Membership resolves and adds these pieces:
- A policy store (
ILatticeAuthorizationPolicyStore) that persists authorization rules durably in a dogfoodedILatticetree, so the policy is itself introspectable through the standard read / scan / change-feed surface. - A decision engine that compiles the rule set into an in-memory snapshot and evaluates a request (subject, operation, tree, key/range) into an allow or deny.
- An enforcing access gate that the core data path consults on every user-originated operation, so a denied write throws and a denied read reports absent - fail-closed.
Registering the package installs the enforcing gate. A cluster that does not register it runs with the core allow-all gate and pays no authorization cost on the data path (see Zero cost when disabled).
Features
| Feature | Public surface | Reference |
|---|---|---|
| Durable, introspectable policy store | ILatticeAuthorizationPolicyStore |
Rule |
| Rule model | LatticeAuthorizationRule, LatticeSubjectSelector, LatticeScope, LatticeEffect, LatticeAuthOperations |
Rule, Scope |
| Subject-relative scopes | LatticeScope.SubjectPlaceholder, LatticeScope.GroupPlaceholder |
Subject-relative scopes |
| Deterministic precedence and default-deny | LatticeAuthOptions.DefaultEffect, LatticeAuthOptions.UserRuleBeatsGroupRuleAtEqualScope |
Precedence |
| Opt-in all-trees tier and access-administration delegation | LatticeAuthOptions.AllTreesGrantsEnabled, LatticeAuthOptions.AccessAdministrationDelegationEnabled |
Configuration |
| Break-glass root of trust | LatticeAuthOptions.BootstrapAdministrators |
Bootstrap administrators |
| In-memory compiled decision engine | ILatticeDecisionEngine |
The compiled snapshot |
| Strict policy-epoch fence | LatticePolicyEpochFenceContext, LatticeAuthOptions.StrictConsistencyTrees |
Consistency modes |
| Reserved rule-id namespaces | LatticeAppRuleIds, LatticeAppOwnedRuleException, LatticeTenantRuleIds, LatticeTenantOwnedRuleException |
Rule, Tenant-tier rule ids |
| Tenant rule layer and tenant-isolation seams | ITenantRuleLayer, ITenantGateEnforcer |
The tenant rule layer |
| Metrics and audit trail | LatticeAuthMetrics, ILatticeAuthAuditSink, LatticeAuthDecisionEvent, LatticeAuthAuditVerbosity |
Observability |
| Admin audit trail | LatticeAdminAuditRecord, LatticeAuthOptions.EnableAdminAuditTrail |
Admin audit trail |
| Opt-in enforcement with zero cost when absent | LatticeAuthServiceCollectionExtensions |
Zero cost when disabled |
Setup
Register the three layers in order on the silo: the core lattice, then membership, then authorization.
siloBuilder
.AddLattice((silo, name) => silo.AddMemoryGrainStorage(name))
.AddLatticeMembership()
.AddLatticeAuth(options =>
{
// Fail-closed: anything not explicitly allowed is denied.
options.DefaultEffect = LatticeEffect.Deny;
// Root-of-trust subjects that bypass policy entirely.
options.BootstrapAdministrators.Add("root-admin");
});
AddLatticeAuth(...) must be called after AddLattice(...) and AddLatticeMembership(). Calling it out of order fails fast at registration with an actionable message rather than failing obscurely at silo start.
Concepts
Subject
Every gated operation is evaluated against the caller's resolved subject: a stable subject id plus the transitively-expanded closure of groups it belongs to (produced by Orleans.Lattice.Membership). A rule can target a subject by user id or by group; a group rule applies to every member without naming them.
Rule
A LatticeAuthorizationRule grants or denies a set of operations to a subject selector at a scope:
var rule = new LatticeAuthorizationRule(
ruleId: "editors-write-orders",
subject: LatticeSubjectSelector.Group("editors"),
scope: LatticeScope.Tree("orders"),
operations: LatticeOperation.Read | LatticeOperation.Write,
effect: LatticeEffect.Allow);
- Subject selector (
LatticeSubjectSelector) targets aUser(id)or aGroup(id). - Operations (
LatticeOperation, a[Flags]set) name the capability classes covered:Read,Write,Delete,RangeRead,RangeDelete,CrdtApply,AtomicWrite,BulkLoad,Admin,Backup,Restore,SchemaAdmin,Telemetry,Replication,TreeLifecycle, andAppInstall. Grants do not imply each other unless the enum member explicitly says so: for example,Writedoes not conferDelete,Admindoes not conferTelemetry, andRestoreauthorizes populating the target scope from a backup without a separateWriteorBulkLoadgrant. A rule matches a request only when its mask contains every operation bit the request carries. - Effect (
LatticeEffect) isAlloworDeny. - Condition is an optional, opaque string reserved for a future claim / attribute predicate language. Nothing evaluates it in this version: a rule carrying a condition matches exactly as an unconditional rule would, so never rely on one to narrow a grant.
LatticeAuthOperations.All is a convenience mask of every tree-scoped data-plane operation, Read through SchemaAdmin. It deliberately excludes Telemetry, Replication, TreeLifecycle, and AppInstall, so a whole-data-plane grant never confers them; each must be granted explicitly. AppInstall is a scopeless, cluster-wide capability granted over LatticeScope.ClusterWide() exactly as Telemetry is; it authorizes the installable-app lifecycle - installing, upgrading and re-consenting, enabling, disabling, reconciling and uninstalling an app, and re-binding its roles to groups - the app-control facade's list, describe and consent reads, and browsing the app catalogue's sources, and confers nothing else.
Rules are authored through the policy store, resolved from the silo's service provider:
public sealed class PolicySeeder(ILatticeAuthorizationPolicyStore store)
{
public async Task GrantAsync(CancellationToken cancellationToken)
{
await store.PutRuleAsync(
new LatticeAuthorizationRule(
"analysts-read-eu",
LatticeSubjectSelector.Group("analysts"),
LatticeScope.Prefix("orders", "eu/"),
LatticeOperation.Read | LatticeOperation.RangeRead,
LatticeEffect.Allow),
cancellationToken);
}
}
Rule ids that start with app: (LatticeAppRuleIds.Prefix; test an id with LatticeAppRuleIds.IsAppOwned) belong to installable apps: the app compiler writes them under system origin and replaces an app's whole set on every reconciliation. The policy store therefore rejects a PutRuleAsync or RemoveRuleAsync of such an id from any caller that is not already running under system origin - a bootstrap administrator included - with LatticeAppOwnedRuleException, an ArgumentException carrying the targeted RuleId. The check runs before anything is read or written, so a rejected delete does not disclose whether the rule exists. To change what an app's users may do, author a separate rule outside the prefix (for example a deny at the same or a more specific scope, which Precedence lets win), or change the app's manifest or role bindings.
Rule ids that start with tenant: (LatticeTenantRuleIds.Prefix) are tenant-tier rules, written by a tenant's own administrators through the tenant-administration facade when delegated tenant access administration is on. The policy store guards them like app: ids: a PutRuleAsync or RemoveRuleAsync of one off system origin throws LatticeTenantOwnedRuleException before anything is read or written. Reads are not guarded, so operators can list them. The store also confines every tenant-tier rule, and every rule naming a tenant group, to the owning tenant's trees, for every caller; see The tenant rule layer.
Rule ids containing U+001F are rejected on write, point read, and delete before storage is touched, so a composite key cannot reinterpret an ordinary id as an app-owned or tenant-tier id. Existing persisted rules remain enforced, including denies. Per-tree lists check the stored rule's exact tree id, even when a tree name contains U+001F.
Before any other check, and before anything is read or written, the store refuses a malformed rule with an ArgumentException: an empty rule id or subject id; an effect, subject kind or scope kind outside the defined values; or a key or prefix that is missing from a key or prefix scope, or present on a whole-tree scope. The public constructors do not check the enum values, and Orleans deserialization and with expressions skip the constructors entirely. When the snapshot compiles, it drops any malformed rule that reached the policy tree by restore or replication, so it never grants or denies.
Scope
A LatticeScope names how broadly a rule applies within a tree, from broadest to narrowest:
| Scope | Factory | Matches |
|---|---|---|
| Tree | LatticeScope.Tree(treeId) |
Every key in the tree. |
| Prefix | LatticeScope.Prefix(treeId, prefix) |
Every key that starts with the prefix. |
| Key | LatticeScope.Key(treeId, key) |
Exactly one key. |
| Tenant capability | LatticeScope.TenantCapability(tenant) |
A whole-tree scope over the tenant's control-plane capability id _lattice_tenant_admin_{tenant} (never the default tenant). A platform rule granting Telemetry here admits its subject to that one tenant's telemetry only; see Tenant-confined telemetry grants. The gate governs the id as a control-plane namespace: an unmatched request is denied whatever the default effect, the all-trees tier never reaches it, and Admin and Telemetry on it are independent. |
| Tenant-wide | LatticeScope.TenantWide(tenant) |
A whole-tree scope over the sentinel tree id t/{tenant}/*, standing for every tree the tenant owns except its app-owned trees. Authorable only on a tenant-tier rule; see The tenant rule layer. |
| Cluster-wide | LatticeScope.ClusterWide() |
A whole-tree scope over the * sentinel tree id, used for a capability not attached to any single tree (LatticeOperation.Telemetry and LatticeOperation.AppInstall) and, once AllTreesGrantsEnabled is set, for a data-plane grant or deny across every application tree (see Precedence). |
Subject-relative scopes
A key or prefix can name the caller instead of a fixed value, so one rule grants every caller their own slice of a tree (#6061). The placeholder is filled in from the caller's resolved subject at decision time:
| Placeholder | Matches a key segment equal to |
|---|---|
{subject} (LatticeScope.SubjectPlaceholder) |
The caller's subject id. |
{group:<prefix>} (LatticeScope.GroupPlaceholder(prefix)) |
The id of any group in the caller's expanded group set that starts with <prefix>, with <prefix> stripped. |
public sealed class OwnershipPolicySeeder(ILatticeAuthorizationPolicyStore store)
{
public async Task SeedAsync(CancellationToken cancellationToken)
{
// Each member may write and delete under their own prefix.
await store.PutRuleAsync(
new LatticeAuthorizationRule(
"owner-write-images",
LatticeSubjectSelector.Group("members"),
LatticeScope.Prefix("images", LatticeScope.SubjectPlaceholder + "/"),
LatticeOperation.Write | LatticeOperation.Delete | LatticeOperation.CrdtApply,
LatticeEffect.Allow),
cancellationToken);
// A member of group "grp:hikers" may read the keys under "g/hikers/".
await store.PutRuleAsync(
new LatticeAuthorizationRule(
"group-read-audience",
LatticeSubjectSelector.Group("members"),
LatticeScope.Prefix("aud", "g/" + LatticeScope.GroupPlaceholder("grp:") + "/"),
LatticeOperation.Read | LatticeOperation.RangeRead,
LatticeEffect.Allow),
cancellationToken);
}
}
- Segment-bounded. Every placeholder must be followed by a literal delimiter, such as
/, and the substituted value runs up to that delimiter, sou1never matches a key ofu10.PutRuleAsyncrefuses a placeholder with no delimiter after it, and a template with more than eight placeholders. - Unmatchable ids are refused silently. An empty id, an id containing the delimiter, an id containing U+001F, and the anonymous caller never match. Nothing throws, so there is nothing to probe.
- Precedence is unchanged. A matched templated rule ranks in its tier by its length after substitution, and competes with a literal rule on the same resolved key or prefix under the usual tie-break, so a fixed per-user deny on
u1/still beats a templated allow. A templated deny, such asDeny Group("suspended")onPrefix(t, "{subject}/"), works too. - Ranges are a plain allow only when the whole range stays inside the caller's resolved prefix; otherwise the decision is filtered key by key, as with a literal prefix.
- Confinement. A templated scope cannot be authored on a control-plane tree (
sys-*,_lattice_*,tag-*). A{group:...}prefix that can reach tenant groups (t/...) must start witht/{tenant}/for the tenant that owns the scoped tree. Anapp:rule always matches its key or prefix literally. - Group changes propagate with membership. The group set is read per decision, so removing a caller from a group revokes their
{group:...}access as soon as their resolved subject reflects it. - Written as authored. The policy store, the explain and introspection surfaces and the Explorer show a templated rule with its placeholders, and
LatticeScope.IsTemplated()reports whether a scope is one.LatticeScope.GetTemplateError()returns the reason the store would refuse a scope's template, so an authoring surface can report it before writing; the Explorer's rule editors do. Any other brace in a key or prefix is literal text, and an invalid template that reaches the policy tree by replication or restore keeps its literal meaning.
A decision adds at most one placeholder match per templated rule on the tree, and one lookup in the caller's group set per group placeholder; it allocates nothing. The enumerations behind range-uniformity checks, existence probes and explanations share a fixed budget per decision across every templated rule of the tree (at most 4096 instantiations and 65,536 steps, and 1024 probed positions); when the budget runs out the answer fails closed: a range is filtered key by key, and a probe reports no grant. The compiled snapshot holds one entry per templated rule, however many callers it serves.
Precedence
When more than one rule matches, the decision engine resolves them deterministically:
- Most-specific scope wins. A hit at a more specific tier (exact key, then longest matching prefix, then tree-wide) is never overridden by a less specific one. A key-scoped allow carves an exception out of a tree-scoped deny, and a key-scoped deny carves a hole out of a tree-scoped allow.
- Within a single scope tier, deny overrides allow. Two sibling rules at the same specificity that disagree resolve to deny (deny-override).
- A user rule outranks a group rule at equal scope (configurable through
UserRuleBeatsGroupRuleAtEqualScope, default on), so a user-specific allow can lift an individual out of a group-level deny. - Default-deny. With no matching rule, the configured
DefaultEffectapplies. The recommended and default posture isDeny, so anything not explicitly granted is refused.DefaultEffectnever applies to a control-plane request - the reservedsys-auth-*andsys-tenant-*namespaces, the schemasys-schema-*and backupsys-backup-*backing stores, the membershipsys-membership-*stores, the shared tag-indextag-*backing trees, the installable-appssys-app-*namespace (the app registry, activation status andsys-app-treestree ownership ledger), the tenant-administration capability ids, and a cluster-wide capability request on the*sentinel (such asTelemetry): there only an explicit matched allow grants access, so an unmatched request is denied even underDefaultEffect = Allow. - All-trees tier (opt-in). With
AllTreesGrantsEnabledset,Tree:*rules also govern every application tree: an all-trees deny wins outright, otherwise the tree's own most-specific verdict applies, otherwise an all-trees allow grants, otherwiseDefaultEffectapplies. The tier never reaches a control-plane namespace; see Configuration. - Tenant layer (opt-in). Every rule above is an operator rule, and a matched operator verdict, allow or deny, is final. With delegated tenant access administration on, a request on a tenant's own tree that no operator rule matches is decided by that tenant's tenant-tier rules before
DefaultEffectapplies: a tenant-wide deny, then the tree's most-specific tenant verdict, then a tenant-wide allow. A tenant rule therefore never overrides an operator rule. See The tenant rule layer.
Bootstrap administrators
BootstrapAdministrators is the root-of-trust: subjects in this set bypass policy entirely and can always read, write, and administer every tree. Use them to seed the very first rules (there is otherwise no one authorized to author policy under default-deny) and for break-glass operations. Keep the set small.
System-tree replication
The policy store and the membership directory are ordinary ILattice trees. In a multi-cluster deployment they are replicated through the Orleans.Lattice.Replication package's system-tree enrolment (ReplicateLatticeSystemTrees()), so a rule authored (or revoked) in one cluster converges to the others. The receiver applies shipped policy writes under a system-origin scope, so a replicated write lands on the destination's default-deny policy tree even though the applier carries no user identity.
Consistency modes
Policy propagation is eventually consistent by default: a rule change is visible once the destination's compiled snapshot rebuilds off the updated policy tree. The change feed that drives a rebuild fires only on the silo hosting the policy leaf that committed the write, so every other silo learns of it through a cluster-wide policy epoch: the committing silo advances the epoch, and every silo reads it about once a second and rebuilds when it has moved, when the epoch grain has restarted, or when cluster membership has changed (a silo that died between committing a write and publishing it). A revoked grant therefore stops admitting on every silo within about a second of the write, plus the rebuild. A rebuild that fails is retried on the next read rather than leaving the old snapshot in force, and the steady state costs one small grain call per second per silo. The one exception is the first rule written to a silo whose snapshot holds none: from that write until a rebuild that saw it completes, the gate makes requests wait for the rebuild rather than answer them from the empty snapshot, so a host that seeds its grants at startup never denies them as unmatched. A tree that needs a caller to observe a policy change before its next operation can opt into a strict epoch fence by naming the tree in StrictConsistencyTrees; while the locally compiled policy epoch is below the floor a caller stamped with LatticePolicyEpochFenceContext.RequireAtLeast, user writes to that tree are rejected (denied) rather than made to wait; a write with no floor stamped takes the eventual path. Reads, system-origin writes, and replication-applied writes are never fenced.
siloBuilder.AddLatticeAuth(options =>
{
options.DefaultEffect = LatticeEffect.Deny;
options.BootstrapAdministrators.Add("root-admin");
// "billing" observes policy changes under a strict epoch fence;
// every other tree stays eventually consistent.
options.StrictConsistencyTrees = new HashSet<string> { "billing" };
});
Zero cost when disabled
The authorization layer is opt-in. The core AddLattice(...) registration installs only the allow-all null gate; AddLatticeAuth(...) replaces it with the enforcing policy gate. A cluster that never registers authorization keeps the null gate, whose decision is a synchronously-completed, allocation-free allow that never resolves a subject - so the data path is byte-for-byte what it was before the authorization layer existed.
Observability
Every authorization decision, the decision latency, the compiled-snapshot rebuild count, and the snapshot epoch / age / policy-coverage gauges are published on a single meter, and an optional audit sink records a durable decision trail. See Observability for the full instrument catalogue and the audit-sink seam; the subject-resolution-cache counters live on the membership meter (see Membership observability).
Public API
Every type below is in the Orleans.Lattice.Auth namespace. The operation vocabulary (LatticeOperation) and the access-gate seam the package plugs into are core types. Every member and signature is listed in the Public API reference.
| Type | Purpose |
|---|---|
LatticeAuthServiceCollectionExtensions |
AddLatticeAuth(configure) installs the enforcing gate; ConfigureLatticeAuth(configure) layers a further LatticeAuthOptions delegate after registration. |
LatticeAuthOptions |
Every knob; see Configuration. |
LatticeAuthorizationRule, LatticeSubjectSelector, LatticeScope |
A rule, its subject selector, and its scope, as described above. LatticeScope.TenantWide(tenant) creates the tenant-wide scope, and IsTenantWide() / TryGetTenantWideTenant(out tenant) recognise it. LatticeScope.TenantCapability(tenant) creates the tenant capability scope, and TryGetTenantCapabilityTenant(out tenant) recognises it. SubjectPlaceholder, GroupPlaceholder(prefix), IsTemplated() and GetTemplateError() author, recognise and pre-check a subject-relative scope. |
LatticeSubjectSelectorKind, LatticeScopeKind, LatticeEffect |
The discriminators: User or Group; Tree, Key, or Prefix; Allow or Deny. |
LatticeAuthOperations |
All, the whole-data-plane operation mask. |
ILatticeAuthorizationPolicyStore |
Durable rule storage: PutRuleAsync, GetRuleAsync, RemoveRuleAsync, ListRulesForTreeAsync, and ListRulesAsync. A write or delete of an app-owned rule id outside system origin throws LatticeAppOwnedRuleException. |
LatticeAppRuleIds |
The app-owned rule-id namespace: Prefix (app:) and IsAppOwned(ruleId). |
LatticeAppOwnedRuleException |
The ArgumentException the policy store throws for a direct write or delete of an app-owned rule id; RuleId names the targeted id. |
LatticeTenantRuleIds |
The tenant-tier rule-id namespace: Prefix (tenant:), For(tenant, localId), IsTenantOwned(ruleId), and TryGetTenant(ruleId, out tenant). See The tenant rule layer. |
LatticeTenantOwnedRuleException |
The ArgumentException the policy store throws for a write or delete of a tenant-tier rule id off system origin; RuleId names the targeted id. |
ITenantRuleLayer |
The on/off seam for the tenant rule layer (IsActive). The default is inactive; Orleans.Lattice.Tenancy supplies the active one, which reads its delegated-access flag. |
ILatticeDecisionEngine |
Evaluates a request against the compiled policy snapshot, synchronously and in memory (Evaluate), and reports the snapshot's CurrentEpoch. It is the policy decision only: the enforcing gate layers the bootstrap-administrator bypass, the control-plane fail-closed rule, tenant isolation, and the strict epoch fence around it. |
LatticeAuthReservedTrees |
The reserved sys-auth-* namespace guard: Prefix, PolicyTreeId, IsReserved(treeId), and ThrowIfReserved(treeId), which throws the same error the policy store enforces. |
LatticePolicyEpochFenceContext |
The caller half of the strict epoch fence: RequireAtLeast(epoch) scopes a required policy-epoch floor onto the ambient request context (nesting never lowers an outer floor), and RequiredEpoch reads it. |
ITenantGateEnforcer |
The tenant-isolation seam the gate consults only for a request the policy already allowed; a deny from either side denies. The gate calls EnforceAsync, which an enforcer completes synchronously on its steady state and may complete asynchronously only to confirm a decision its warm state cannot answer; its default implementation returns the synchronous Enforce decision. The default is an inactive allow-everything implementation, and Orleans.Lattice.Tenancy supplies the active one. |
ILatticeAuthAuditSink, LatticeAuthDecisionEvent, LatticeAuthAuditVerbosity |
The audit seam, its value-free decision event, and its verbosity; see Observability. |
LatticeAuthMetrics |
The orleans.lattice.auth meter and its instrument and tag names; see Observability. |
Reference
- Public API - every public type and member, with source links.
- Configuration - every public options property, its type, and its default.
- Architecture - the policy store, compiled snapshot, epoch propagation, and the enforcing gate's decision order.
- The tenant rule layer - how tenant-tier rules are evaluated beneath operator rules, and the guards that confine them to their tenant.
- Security posture - threat model, attack surface, fail-closed guarantees, the internal-grain trust boundary, the bootstrap-administrator root of trust, and TLS expectations.
- Observability - the
orleans.lattice.authmeter and the audit sink.
See also
Orleans.Lattice.Membership- the identity directory and subject-resolution pipeline this layer authorizes against.Orleans.Lattice.Api.Auth- the transport-agnostic control facade for administering membership and policy and explaining decisions.Orleans.Lattice.Replication- the system-tree replication that converges policy and membership across clusters.