rennf93/guard-core-php
Framework-agnostic core for Guard, the PHP authentication and authorization library. Provides reusable primitives for guards, identity checks, and access control, usable in standalone PHP apps or alongside Laravel and other frameworks.
Architecture fit. The package fits as Laravel HTTP middleware/engine for application-layer detection, IP access control, dynamic rules, response modification, and agent-backed telemetry. v4.4.0 aligns with core engines at 4.4.0 and adds useful seams: a per-request regex CPU budget, semantic-header exclusions, a response modifier hook, and request metrics. It is best treated as defense-in-depth alongside edge WAF/CDN controls, not as a replacement.
Integration feasibility. Standard Laravel integration is feasible, but this is a behavior-heavy release, not a drop-in patch. Feasibility depends on current use of the agent, dynamic rules, enrichment, trusted proxies, IP lists, and custom response handling. The new config validation requiring enableAgent when enableDynamicRules or enableEnrichment is on can block deployment if existing configs are not updated. Metrics require an agent handler exposing sendMetric; dynamic rules require an agent handler exposing getDynamicRules().
Technical risk. Medium-high for production adoption. Key risks:
ip_blacklist is now a timed ban through the engine ban manager, ip_whitelist unbans, versions apply over base config, failed applies keep the prior version, expiry restores base, and emergency mode halves the auto-ban threshold once.detectionMaxScanSeconds limits regex scan CPU per request, but direct detect() calls outside a request scan are not capped and need separate safeguards.logSensitiveHeaders address-header workarounds should be removed per docs; removing them can re-enable detection on headers that were previously skipped, creating new findings.Key questions.
trustedProxies and forwarded-header depth are configured?enableAgent enabled and is a compatible agent handler attached?customResponseModifier needed, and can it safely fail without affecting security headers or CORS?GuardEngine::detect() calls outside middleware that bypass the new scan budget?Stack fit. The middleware model is a good fit for Laravel request/response handling. The response modifier seam supports adapters that need to alter pass-through responses. Agent-backed dynamic rules and metrics fit environments that already run the matching agent/core version. Compatibility with core engines is explicitly lockstep at 4.4.0, so agent, core, and package versions should be managed together.
Migration path.
enableAgent, enableDynamicRules, enableEnrichment, agentEnableEvents, agentEnableMetrics, trustedProxies, IP lists, route overrides, and any logSensitiveHeaders workaround.enableAgent wherever dynamic rules or enrichment are enabled; otherwise disable those features explicitly.X-Forwarded-For, empty entries, over-counted proxy depth, mapped IPv6, zoned addresses, malformed CIDRs, and unix peer cases.ip_blacklist timed ban, ip_whitelist unban, blocked countries, cloud-provider blocks, user-agent blocks, endpoint rate limits, version failure/expiry, and emergency mode.Compatibility. Treat v4.4.0 as a minor-version release with breaking behavioral changes. Pin the package version and the matching agent/core versions. Do not mix v4.4.0 with an older agent handler that lacks getDynamicRules() or sendMetric if those features are enabled.
Sequencing. Use a staged rollout: preflight config and proxy review, staging with enforcement disabled or passive where possible, canary with metrics and log review, then production. Keep a rollback plan that includes reverting config, not just the package version, because validation and rule semantics changed.
Maintenance. Maintain configuration as code and review diffs for proxy, IP-list, and dynamic-rule changes. Track package, agent, and core-engine versions together. Expect ongoing tuning of detectionMaxScanSeconds, IP list size, and semantic-header exclusions. Any custom response modifier becomes application-owned code and needs tests.
Support. Publish runbooks for pattern_timeout, spoofing_detected, dynamic-rule apply failures, emergency mode activation, and unexpected IP-list denials. Update log parsers for the passive-mode wording change. Support teams should know that dynamic rule changes may be delayed by dynamicRuleInterval (minimum 60 seconds, default 300), so it is not an instant-update mechanism.
Scaling. The per-request scan budget reduces regex CPU worst cases but does not eliminate scanning cost. Benchmark large IP lists, many patterns, and metrics emission under representative traffic. Request metrics add value but also agent and telemetry overhead. Dynamic rule polling is interval-gated, which helps control agent load but introduces rule staleness. Response modification runs on every returned response and should be lightweight.
Failure modes.
enableAgent.pattern_timeout threat and may trigger blocking; tune carefully to avoid false positives.Ramp-up. Plan a multi-sprint hardening cycle rather than a routine dependency bump: one track for Laravel/agent integration and config validation, one for security-operations validation of proxy identity, IP lists, dynamic rules, logging, and rollback. Canary traffic and side-by-side log review are strongly recommended before broad enforcement.
How can I help you explore Laravel packages today?