Download the PHP package micro-module/ist-auth-bundle without Composer
On this page you can find all versions of the php package micro-module/ist-auth-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download micro-module/ist-auth-bundle
More information about micro-module/ist-auth-bundle
Files in micro-module/ist-auth-bundle
Package ist-auth-bundle
Short Description Pure HttpKernel JWT/IST authentication bundle for Symfony
License MIT
Informations about the package ist-auth-bundle
micro-module/ist-auth-bundle
Pure HttpKernel JWT/IST authentication bundle for Symfony 8.
Validates Inter-Service Tokens (IST — JWT HS256) via pure symfony/http-kernel
event listeners. No symfony/security-bundle, no UserInterface, no Voter,
no firewall YAML.
Designed for inter-microservice authentication where a monolith (or any upstream service) mints short-lived HS256 JWTs and downstream microservices validate them per request without pulling in the full Symfony security stack.
Why this bundle exists
symfony/security-bundle is designed for session-based user authentication.
For stateless service-to-service JWTs it brings significant complexity
(firewalls, authenticators, passports, voters, user providers) and couples
every consumer to a heavy authentication lifecycle.
This bundle takes the opposite approach:
- 5 HttpKernel event listeners with locked priorities
- Single
PrincipalStaterequest attribute for principal propagation - Config-driven route policies (19+ entries in a typical consumer)
- Optional
#[IstAuthLevel]attribute for per-controller overrides - Published
Contracts\*namespace — consumers import only stable types
Total production footprint: ~40 classes, ~3,500 LOC.
Features
| Area | Capability |
|---|---|
| JWT validation | HS256-pinned, typ=IST enforced, 8KB payload cap, JSON depth ≤8, hash_equals via firebase/php-jwt |
| Algorithm confusion | Pre-decode alg === 'HS256' check, segment base64url regex, RSA-pubkey-as-HMAC defence (TG-01) |
| Policy engine | PCRE route-name matching, fail-safe REQUIRED default, 4 auth levels (None, Required, ExhibitorOwner, Admin) |
| Admin resolution | 3 strategies (allowlist, claim, audience-based) selectable via config |
| Resource ownership | Consumer-implemented ResourceOwnershipCheckerInterface port |
| Sub-request isolation | RequestStack depth ≤3, strips Authorization header, resets state |
| Bypass routes | Byte-anchored regex on _route name only (no path traversal) |
| Error envelopes | ER-1 (401) / ER-2 (403) from enum reasons — never $exception->getMessage() |
| Observability | Correlation-ID propagator, Monolog JWT redactor, Prometheus metrics, OTel span attrs |
| Anti-replay | Optional JTI guard with Redis + in-memory stores (opt-in via anti_replay.enabled) |
| OpenAPI | Auto-declares bearerAuth scheme via Nelmio post-processor |
| Audit | Dedicated security Monolog channel for SIEM |
Requirements
- PHP 8.4
- Symfony 8.0 (http-kernel, http-foundation, config, dependency-injection)
firebase/php-jwt^7.0monolog/monolog^3.0predis/predis^2.2 (only if usingRedisReplayStore)open-telemetry/api^1.0 (no-op without the SDK; see suggested packages)
Installation
Register the bundle in config/bundles.php:
Configuration
Create config/packages/ist_auth.yaml:
Environment variables:
Fail-safe default: routes not matched by any route_policies entry are
treated as REQUIRED. Unknown paths never default to public.
Usage
Reading the principal in a controller
Type-hint the principal argument — the bundle's argument resolver injects the correct instance:
Per-controller policy override (optional)
Attribute values merge with config policies; config wins on conflict.
Implementing resource ownership
Consumers provide a thin adapter in their own Infrastructure layer:
Register the alias (or tag autowire: true):
Architecture
Listener topology (priorities are locked)
| Priority | Event | Listener | Purpose |
|---|---|---|---|
| 128 | kernel.request |
BypassRouteListener |
Match _route name against bypass regex; skip auth |
| 96 | kernel.request |
SubRequestIsolationListener |
Reset state on sub-requests, cap depth at 3, strip Authorization |
| 64 | kernel.request |
IstAuthenticationListener |
Extract Bearer, validate JWT, write PrincipalState |
| 32 | kernel.request |
IstAuthorizationListener |
Match route policy, enforce level + ownership |
PHP_INT_MAX/2 |
kernel.exception |
IstExceptionListener |
Map validation/authz exceptions → ER-1 / ER-2 |
| -10 | kernel.response |
CorrelationIdResponseListener |
Echo X-Correlation-Id header |
Canary tests (ListenerPriorityCanaryTest) use EventDispatcher::getListenerPriority()
to lock these priorities — any drift is a merge blocker.
Layer structure
Enforced by depfile.yaml (Deptrac):
Contractsdepends on NOTHING in this bundleInfrastructuremay not depend onPresentation- Consumer code must only import
Contracts\*
Security invariants
The following are enforced by tests and CI scripts — any violation is a merge blocker:
- Algorithm pinning —
alg === 'HS256'strict equality before signature verification (src/Domain/Validator/) - Segment base64url validation before
json_decode(defeats byte injection,scripts/ci/no-raw-jwt.sh) hash_equalsvia firebase/php-jwt — never rolled locally- Payload ≤ 8KB, JSON depth ≤ 8 — DoS defence
- Secrets ≥ 43 base64url chars — boot-time fail-to-start
typ === 'IST'strict, case-sensitive- No
$e->getMessage()in error envelopes (SR-7,scripts/ci/forbidden-getmessage.sh) - Raw JWT never logged —
AuthorizationHeaderRedactorMonolog processor - Correlation-ID sanitized with
\A[A-Za-z0-9_-]{1,128}\z(byte-anchored, not^…$) - Bypass matches
_routename only — never raw paths
See tests/Unit/Domain/Validator/ for the full algorithm-confusion matrix
(lowercase alg, none, RS256, RS384, RS512, ES256, PS256 — all rejected).
Development
All commands run from the bundle repo root:
Local development with a consumer service
When developing the bundle alongside a consuming project, use Composer's path repository feature:
Note the per-package preferred-install override — without it, a global
"dist" setting silently converts the symlink into a copy.
Versioning
Development tags:
v0.1.0-dev— Bundle foundation (AbstractBundle + config schema)v0.2.0-dev— Domain + HS256 validator + exception hierarchyv0.3.0-dev— HttpKernel listeners, observability, error envelopes, anti-replay, News-MVP integration surface
v1.0.0 ships after full GATE-9G verification (24 acceptance criteria
- K6 p95 ≤ 1.8 ms + security review sign-off).
License
MIT. See LICENSE.
Contributing
Issues and pull requests welcome at https://github.com/temafey/micro_modules_ist_auth_bundle.
Security reports: follow the coordinated disclosure protocol documented in
SECURITY.md (7-day triage SLA).
All versions of ist-auth-bundle with dependencies
firebase/php-jwt Version ^7.0
monolog/monolog Version ^3.0
open-telemetry/api Version ^1.0
predis/predis Version ^2.2 || ^3.0
psr/log Version ^3.0
symfony/config Version ^8.0
symfony/dependency-injection Version ^8.0
symfony/http-foundation Version ^8.0
symfony/http-kernel Version ^8.0