Skip to content
Wallet and Entity Collection draft updates
Documentation menu

5.3. Constrain paths, names, and entity types

Feature guides / 5. Federation policy · Example context

SWAMID lets Umeå University enroll its services, but wants to limit how far that authority can delegate and which domain names it can endorse.

How to use it

Publish constraints in the Subordinate Statement about that authority. max_path_length bounds subordinate authority depth; naming_constraints restricts hosts; allowed_entity_types constrains metadata types. The full chain validator applies these in their proper scope.

import { entityId, type TrustChainConstraints } from "@oidfed/core";
import type { TrustAnchor, Intermediate } from "@oidfed/authority";

export async function constrainUniversity(swamid: TrustAnchor | Intermediate) {
  const constraints: TrustChainConstraints = {
    max_path_length: 1,
    naming_constraints: { permitted: ["umu.example", ".umu.example"] },
    allowed_entity_types: ["openid_provider", "openid_relying_party"],
  };
  await swamid.updateSubordinate(entityId("https://umu.example"), { constraints });
}

The statement is issued by SWAMID about the university. A limit of 1 permits the university Intermediate between SWAMID and the OP, while preventing another authority level below it. The permitted names include both the university Entity Identifier and its service subdomains.

What your application owns

Use DNS host/domain patterns, not full URLs. A leading dot names subdomains; it is not a general wildcard language. Do not put federation_entity into allowed_entity_types: its implicit status differs from protocol types. Test the intended topology before publishing restrictive policy, especially when authorities serve more than one role. Unknown constraint parameters remain ignored unless the consumer registers a handler.

Test a path, not one statement

A naming or path-length constraint affects subordinate paths below the statement carrying it. Test the complete SWAMID-to-university-to-OP path. The university contributes one Intermediate between the constraint issuer and the OP. Adding another authority below it exceeds this example's configured limit.

Use DNS-domain patterns for naming constraints, not complete URLs. Keep path constraints separate from application authorization: an allowed entity type means the chain can carry that metadata type, not that a user has permission to access LIGO Wiki. A rejected constraint requires a different valid path or an explicit policy change.

Constraint scope and parameter rules

Check maximum path length and permitted/excluded names against a parsed chain. validateTrustChain() runs the chain-level constraint checks and applies allowed_entity_types when resolving metadata.

naming_constraints applies to the subject of the Subordinate Statement carrying it and to that subject's subordinates, as specified in Federation §3.1.3. The issuer is outside its own constraint. Hostname matching follows §6.2.2, with excluded names taking precedence over permitted names. A violation invalidates the chain under §6.2.

max_path_length sets the maximum number of Intermediate Entities between the issuer of the constraint and the Trust Chain subject. Federation §6.2.1 requires a non-negative integer and specifies no upper bound. The schema accepts non-negative JavaScript safe integers. Local discovery work is bounded separately by maxChainDepth, maxAuthorityHints, maxResolutionSteps, and maxTotalFetches; a large constraint value does not increase those budgets.

allowed_entity_types accepts non-empty Entity Type identifiers, including custom types permitted by Federation §5.1. Omit the constraint to allow all types, or use [] to retain only federation_entity. That type is always retained and must not appear in the array. Filtering follows §6.2.3; applications validate the protocol-specific metadata they use.

Discovery and protocol roles enforce these constraints during chain validation. Applications do not need a second checkConstraints() call. The standalone helper is available to custom validation engines through the policy API.

Naming patterns are DNS host/domain names. Matching ignores DNS case and a terminal root dot. host.example.com matches that host; .example.com matches its subdomains and excludes the domain itself. URL strings, IP literals, paths, ports, whitespace, and wildcard patterns are rejected.

Next: 5.4. Enforce a custom federation constraint

View source on GitHub