nowo-tech / dns-kit-bundle
DNS management for multi-tenant Symfony hosts: per-tenant provider connections with sealed API tokens, a provider-neutral DnsProviderInterface port with a Cloudflare adapter (zones and records CRUD, idempotent writes), SSRF-guarded outbound calls, access / tenant / actor ports, post-commit events wi
Package info
github.com/nowo-tech/DnsKitBundle
Type:symfony-bundle
pkg:composer/nowo-tech/dns-kit-bundle
Fund package maintenance!
Requires
- php: >=8.2 <8.7
- ext-intl: *
- ext-json: *
- ext-mbstring: *
- ext-sodium: *
- doctrine/dbal: ^3.8.2 || ^4.0
- doctrine/doctrine-bundle: ^2.8 || ^3.0
- doctrine/orm: ^3.7
- doctrine/persistence: ^3.4 || ^4.0
- nowo-tech/outbound-url-guard-bundle: ^1.5
- nowo-tech/transaction-contract: ^1.1
- nowo-tech/transaction-doctrine: ^1.10.1
- psr/clock: ^1.0
- psr/event-dispatcher: ^1.0
- psr/log: ^2.0 || ^3.0
- symfony/clock: ^7.4 || ^8.0
- symfony/config: ^7.4 || ^8.0
- symfony/console: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/event-dispatcher: ^7.4 || ^8.0
- symfony/framework-bundle: ^7.4 || ^8.0
- symfony/http-client: ^7.4 || ^8.0
- symfony/http-client-contracts: ^3.5
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/uid: ^7.4 || ^8.0
- twig/extra-bundle: ^3.12
- twig/string-extra: ^3.12
Requires (Dev)
- deptrac/deptrac: ^4.7.2
- dragonmantank/cron-expression: ^3.4
- friendsofphp/php-cs-fixer: ^3.95
- igor-php/igor-php: ^0.11
- nowo-tech/audit-kit-bundle: ^2.1
- nowo-tech/doctrine-encrypt-bundle: ^2.15
- nowo-tech/instance-settings-bundle: ^1.25
- nowo-tech/phpstan-frankenphp: ^1.4
- nowo-tech/ui-kit-bundle: ^2.77
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.3
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.5
- rector/rector: ^2.8
- symfony/browser-kit: ^7.4 || ^8.0
- symfony/css-selector: ^7.4 || ^8.0
- symfony/form: ^7.4 || ^8.0
- symfony/messenger: ^7.4 || ^8.0
- symfony/phpunit-bridge: ^7.4 || ^8.0
- symfony/scheduler: ^7.4 || ^8.0
- symfony/security-bundle: ^7.4 || ^8.0
- symfony/security-csrf: ^7.4 || ^8.0
- symfony/translation: ^7.4 || ^8.0
- symfony/twig-bundle: ^7.4 || ^8.0
- symfony/var-dumper: ^7.4 || ^8.0
- symfony/yaml: ^7.4 || ^8.0
Suggests
- nowo-tech/audit-kit-bundle: Audit sink bridge (audit.auditkit): connection, zone and record writes in the action log (^2.1)
- nowo-tech/doctrine-encrypt-bundle: Secret box bridge (secrets.box: doctrine_encrypt): seal provider tokens with a DoctrineEncrypt Halite / Defuse profile (^2.15; Beacon)
- nowo-tech/instance-settings-bundle: Serve the runtime settings (timeouts, retries, limits, audit mode) from the database (instance_settings.enabled, ^1.25)
- phpunit/phpunit: Nowo\DnsKitBundle\Testing\DnsProviderContractTestCase for your own provider adapters
- symfony/security-bundle: Role-based default access checker (security.*_roles) and the user-identifier actor resolver
Provides
None
Conflicts
- nowo-tech/ui-kit-bundle: <2.77
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 10:54:40 UTC
README
⭐ Found this useful? Install it from Packagist and give it a star on GitHub: it helps us maintain and improve the project.
DNS management for multi-tenant Symfony hosts. Each tenant connects its DNS provider accounts (a label and an API
token); the token is checked, sealed with authenticated encryption bound to the tenant and the connection, and never
shown again except its last four characters. Zones and records are listed and changed through one provider-neutral
port, with a Cloudflare adapter first: idempotent writes, a typed-name check before a zone delete, post-commit
events with TXT values hashed, and outbound calls only to api.cloudflare.com.
Standard Symfony by default, DDD / hexagonal opt-in: a standard host gets role-based access, a single tenant and a sodium secret box from the environment; a DDD host plugs its own access checker, tenant gate, tenant and actor resolvers, secret box and settings provider. The public API is interfaces, value objects and enums with no Symfony, Doctrine or HTTP types; the kit's two tables are mapped read-only and written through DBAL write units.
📋 Compatible with Symfony 7.4, 8.0 and 8.1 · PHP 8.2+ (Symfony 8.x requires PHP 8.4+)
This bundle is FrankenPHP worker mode friendly.
Features
- Connections per tenant: label (unique per tenant) + API token; checked before it is stored (only an active token
is accepted), sealed with XChaCha20-Poly1305 bound to
tenant + connection(a sealed token copied to another row or tenant does not open), only****last4ever readable; Cloudflare global API keys refused; no env fallback. - Provider port
DnsProviderInterfacewithProviderCapabilities(proxying, minimum TTL, record types, page sizes) and a shipped conformance suite (Nowo\DnsKitBundle\Testing\DnsProviderContractTestCase) for later providers. - Cloudflare adapter: token verify with scope probes (a scope that cannot be proven is
Unknown, neverPresent), account list, zone and record CRUD (A, AAAA, CNAME, TXT, MX, CAA, SRV with TTL, proxied, priority, comment), optional SSL-mode and registrar-expiry enrichments (missing scope = a gap, never a failure). - Outbound safety: the constant base URL
https://api.cloudflare.com/client/v4/, OutboundUrlGuard on every call (public IP pinned, private / loopback / metadata refused), no redirects, idle timeout and total duration cap, response size cap, 429 / 5xx backoff in the console only (a web request never sleeps), and an env-only kill switch. - Idempotent writes: an optional idempotency key per call (stored outcome replayed without a provider call), plus "already exists" / "already gone" mapped to success after an exact lookup; every write recorded in a compact write log (ids and codes, never values).
- Zone delete safety: the typed zone name is compared with the provider's zone name in the service, before any call.
- Tenancy and access: every lookup is
(tenant, id)with a byte-exact re-check; a foreign id answers "not found"; access checker (deny by default), tenant gate (plan module), tenant and actor resolvers as host ports. - Events and audit after the bundle's unit: ids, action, record type and name, values with TXT
sha256:-hashed; a PSR-3 audit sink by default, the AuditKit bridge when installed. - Concurrency (REQ-RUNTIME-003): provider calls never run inside a transaction (refused if they would), short DBAL
write units, a per-connection row lock for the bookkeeping,
CONFLICT_001/CONFLICT_002, a per-tenant slot cap that holds under concurrent adds; two-connection race tests on MySQL, MariaDB and PostgreSQL. - Runtime settings (REQ-RUNTIME-004):
DnsKitSettingsProviderInterfaceserves timeouts, retries, limits and the audit mode from the configuration or, opt-in, from Instance Settings; env-only security controls never come from a database. - Snapshot (0.2.0, opt-in): per-connection zones and records stored by a leased, paced, fetch-first refresh
(Messenger handler, Scheduler bridge, console), read by
DnsSnapshotReaderInterfacewithout calling the provider; zone tombstones for 30 days,expectedVersionchecks on writes, chunked connection removal and tenant erasure. - Pages (0.2.0, opt-in): read-only UiKit pages for connections (Test connection, rename, replace the token, remove, refresh with 202), zones and records, and the refresh state; access-check events on every person check.
- Console:
nowo:dns-kit:connection:{add,check,list,remove,purge},nowo:dns-kit:zones:list,nowo:dns-kit:refresh,nowo:dns-kit:snapshot:purge,nowo:dns-kit:tenant:erase,nowo:dns-kit:secrets:rotate,nowo:dns-kit:schema-check(the token is read from a hidden prompt or STDIN, never an argument). - FrankenPHP worker mode with the kernel not reset: services hold configuration only; a 500-call two-tenant worker test runs in CI.
- 10 locales (en, es, it, fr, pt, de, nl, ca, eu, gl), translation domain
NowoDnsKitBundle.
0.1.0 ships the port, the Cloudflare adapter, connections, the services, events, the console and the contract test kit; 0.2.0 adds the snapshot with its refresh and the optional read-only pages. The write dialogs come in 0.3.0 (ROADMAP.md).
Installation
composer require nowo-tech/dns-kit-bundle
With Symfony Flex the recipe registers the bundle and writes config/packages/nowo_dns_kit.yaml. Generate a sodium
root key into your environment, create the two tables with your migrations or the schema tool
(docs/INSTALLATION.md), then:
bin/console nowo:dns-kit:schema-check bin/console nowo:dns-kit:connection:add "Main Cloudflare" --tenant=acme --actor=admin # token: hidden prompt bin/console nowo:dns-kit:zones:list <connection id> --tenant=acme
Requirements
- PHP >= 8.2, < 8.7 with
ext-sodium,ext-intl,ext-json,ext-mbstring - Symfony 7.4, 8.0 or 8.1; Doctrine DBAL 3.8+ / 4, ORM 3.7+, DoctrineBundle 2.8+ / 3
nowo-tech/transaction-contract^1.1,nowo-tech/transaction-doctrine^1.10.1,nowo-tech/outbound-url-guard-bundle^1.5- MySQL 8.4, MariaDB 11.4, PostgreSQL 16+ or SQLite
- Optional:
symfony/security-bundle(role checker, user actor),nowo-tech/doctrine-encrypt-bundle^2.15 (secret box bridge),nowo-tech/audit-kit-bundle^2.1 (audit bridge),nowo-tech/instance-settings-bundle^1.25 (runtime settings from the database),phpunit/phpunit(provider contract test kit)
Configuration
A standard host only needs the root key (from the environment) and the role mapping:
nowo_dns_kit: secrets: keys: '%env(json:NOWO_DNS_KIT_KEYS)%' # {"k2026":"<base64 of 32 random bytes>"} current_key_id: '%env(NOWO_DNS_KIT_CURRENT_KEY_ID)%' security: dashboard_roles: [ROLE_ADMIN] # View manage_roles: [ROLE_ADMIN] # Create / Edit / Delete settings_roles: [ROLE_ADMIN] # Manage connections
A multi-tenant host aliases its ports (gate, security.access_checker, tenant_resolver, actor_resolver,
secrets.box: doctrine_encrypt). Every key, its default, its range and whether it is env-only:
docs/CONFIGURATION.md.
Usage
Standard Symfony host: call the services with a context:
$ctx = DnsCommandContext::forActor(new TenantRef('default'), $actorResolver->current(), new IdempotencyKey($submitId)); $view = $connections->add($ctx, new ConnectionLabel('Main'), new DnsApiToken($request->request->getString('token'))); $zone = $zones->create($ctx, $view->id, new ZoneName('example.com')); // ->nameServers for the registrar $records->create($ctx, $view->id, $zone->zoneId, new RecordInput( RecordName::inZone('www', new ZoneName('example.com')), RecordContent::of(RecordType::A, '192.0.2.10'), new Ttl(Ttl::AUTOMATIC), proxied: false, )); $zones->delete($ctx, $view->id, $zone->zoneId, new ZoneDeletion(new ZoneName($typedByThePerson)));
DDD / hexagonal host: implement the ports (access checker, tenant gate, resolvers, secret box, audit sink, settings provider) in your infrastructure layer, alias them, and call the application services from your command handlers, outside any transaction.
Both paths in full, the console, the errors and their HTTP mapping, idempotency, events and the provider contract test kit: docs/USAGE.md. Cloudflare token permissions: docs/CLOUDFLARE.md.
Demo
demo/symfony8 (Symfony 8.1, PHP 8.5, http://localhost:8281): FrankenPHP worker mode, MySQL 8.4, UiKit layout, and
the kit wired to an in-memory fake of the Cloudflare API (no real token, no outbound request). make -C demo up-symfony8, then make -C demo/symfony8 seed (adds the demo connection with a random fake token) and sign in as
admin or viewer (password demo). See docs/DEMO-FRANKENPHP.md.
Documentation
- Installation
- Configuration
- Usage
- Contributing
- Code of Conduct
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
- Roadmap
Additional documentation
- Cloudflare tokens and scopes
- Architecture
- Concurrency
- FrankenPHP worker audit
- Privacy
- Contract
- Owner questions and answers
- Demo with FrankenPHP
- GitHub Actions CI
- PSR evaluation
Tests and coverage
- Unit, architecture, integration and database suites (PHPUnit): value objects, the Cloudflare client, mapper and
adapter against a fake API (
MockHttpClient, no real call, no real token), the provider conformance suite, the secret boxes, the services end to end, the secret-leak canary, tenant isolation, SSRF, the console, the container wiring of a standard and a DDD host, and a worker test (one kernel, 500 calls alternating two tenants, flat memory). The database suite runs on SQLite and, in CI, on MySQL 8.4, MariaDB 11.4 and PostgreSQL 17, including the two-connection race tests. - Coverage:
- PHP: 100%
- TS/JS: N/A
- Python: N/A
License
MIT. See LICENSE.
Author
Created by Héctor Franco Aceituno at Nowo.tech.

