5 min readCalm pace · scan the outline anytime

Identity ↔ Directory

Greenfield cookbook — authentication ownership in Identity, member profile/eligibility in Directory, bridged by ACL and Events.

Cookbook — Identity ↔ Directory

Illustrative bounded contexts only. Rename to your domains; do not import product module trees.

ModuleOwns
IdentityCredentials, sessions/tokens, authentication challenges, “who is signed in”
DirectoryMember/organisation profile, roles as Directory sees them, eligibility tiers

Design test: If Identity is replaced by an external IdP, Directory Application/Domain still compile (Directory talks to a local port / events — not Identity Entities).

Bridges used

NeedBridge
Directory must know “subject X is authenticated” for an admin actionSync ACL to Identity or host middleware that already resolved a subject code into the Use Case DTO
After signup, Directory creates a member shellDomain Event IdentityUserRegistered → Directory translation listener → inbound Use Case
Ordering checks member tierSync ACL Ordering → Directory (Identity not involved)

Folder sketch

Identity/
  Domain/
    Events/UserRegistered.php          # rich: userId, email hash/code, occurredAt, schemaVersion, eventId
    Ports/Module/IdentityAuthModuleInterface.php   # thin: validate token / resolve subject
  Application/UseCases/Auth/…
  Infrastructure/…

Directory/
  Domain/Ports/Acl/AuthenticatedSubjectPortInterface.php   # optional if Directory must verify
  Domain/Ports/Module/DirectoryMemberModuleInterface.php   # thin: getTier(memberCode), …
  Application/UseCases/Member/ProvisionMemberFromRegistrationUseCase.php
  Infrastructure/
    ExternalServices/…                 # ACL adapters
    Messaging/IdentityUserRegisteredTranslationListener.php

Sequence — register then provision

Sequence — resolve subject for a Directory admin action

Prefer resolving the subject in UI/Infrastructure (host auth middleware) and passing a subject code into the Directory Application DTO. If Directory Application must verify:

Directory Use CaseAuthenticatedSubjectPortInterface → ACL → IdentityAuthModuleInterface::resolve(token) → local result DTO.

Never inject IdentityAuthModuleInterface into Directory Use Cases.

Ownership pitfalls

PitfallFix
Directory stores passwordsCredentials stay in Identity
Identity stores member pricing tierTier is Directory (or another BC); Identity may only hold auth attributes
Shared User entity for bothSplit models; share only opaque userId / memberCode via contracts
Filament/admin in Directory importing Identity EloquentACL or host auth bridge

Also see Ordering ↔ Warehouse.

Modular Hexagonal Domain-Driven Design
Core 1.0.0-draft