Download the PHP package waffle-commons/security without Composer

On this page you can find all versions of the php package waffle-commons/security. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package security

Discord PHP Version Require PHP CI codecov Latest Stable Version Latest Unstable Version Total Downloads Packagist License

Waffle Security Component

Release: 0.1.0-beta6  |  CHANGELOG.md

Hierarchical Attribute-Based Access Control (ABAC) for the Waffle Framework with a fail-closed default (SEC-02), a fully stateless HMAC CSRF subsystem bound to a per-browser anonymous SID (SEC-01 option C), and a container decorator (SecureContainer) that hardens service retrieval. Security is enforced by PSR-15 middleware sitting between routing and dispatch.

Beta-2 status

No behavioural changes since Beta-1 โ€” lockstep version bump only. The security architecture remains as described below.

๐Ÿ†• Beta-1 foundations (still current)

๐Ÿ“ฆ Installation

๐Ÿงฑ Surface

Class Role
Waffle\Commons\Security\Security SecurityInterface implementation. Reads waffle.security.level from ConfigInterface at construction (defaults to 1).
Waffle\Commons\Security\Abstract\AbstractSecurity Shared base storing the configured security level and providing the analyze() walk.
Waffle\Commons\Security\Middleware\SecurityMiddleware PSR-15 middleware that runs SecureContainer::analyze($controller, $method) โ€” fail-closed ABAC.
Waffle\Commons\Security\Middleware\AnonymousSessionMiddleware PSR-15 middleware that issues / reuses the WAFFLE_SID cookie and publishes the SID as the _anon_sid request attribute. Required upstream of CsrfMiddleware.
Waffle\Commons\Security\Middleware\CsrfMiddleware PSR-15 middleware enforcing #[RequiresCsrfToken]. Validates the signed token against (id, sessionId).
Waffle\Commons\Security\Csrf\CsrfTokenManager final readonly stateless HMAC-SHA256 token manager. Constructor takes a 32+ byte secret.
Waffle\Commons\Security\Container\SecureContainer Decorator over Waffle\Commons\Contracts\Container\ContainerInterface. Beta-1: analyze() is now fail-closed โ€” empty voter list โ‡’ SecurityException(403) unless #[PublicAccess] is present.
Waffle\Commons\Security\Rule\Level1Rule โ€ฆ Level10Rule The ten built-in security levels (1 = public โ€ฆ 10 = god-mode).

๐Ÿšฆ The security ladder

Each LevelNRule lives in src/Rule/. Levels are integer-coded via Waffle\Commons\Contracts\Constant\Constant::SECURITY_LEVEL1 โ€ฆ SECURITY_LEVEL10. The kernel reads waffle.security.level from the application's app.yaml and constructs Security with that level.

The exact constructor, verbatim from src/Security.php:

๐Ÿท๏ธ #[Rule] โ€” declaring required levels

The attribute lives in the contracts package (Waffle\Commons\Contracts\Security\Attribute\Rule). Apply it to controller methods or classes:

If Security::analyze() is invoked against a controller method that requires a level higher than the kernel's configured level, a SecurityExceptionInterface is thrown and the ErrorHandlerMiddleware renders it as RFC 7807 403.

๐Ÿšช Fail-closed ABAC + #[PublicAccess] (Beta-1 / SEC-02)

A controller action without any #[Voter] is now denied with HTTP 403 unless it explicitly carries #[PublicAccess]. Forgetting to attach a voter no longer silently grants access โ€” missing policy is treated as denial.

A method-level #[Voter] always wins over a class-level #[PublicAccess], so mixed-policy controllers stay safe.

๐Ÿ›‚ CSRF โ€” stateless signed double-submit with per-browser binding (Beta-1 / SEC-01)

CsrfMiddleware enforces #[RequiresCsrfToken] using HMAC-signed self-validating tokens. No cache, no Redis, no PHP sessions. Wire format (binary, then base64url):

Two pieces of context are folded into the HMAC:

Operational requirements:

  1. Provide a 32+ byte signing secret. Production refuses to boot without one. Config key waffle.security.csrf.secret, with env fallback WAFFLE_CSRF_SECRET.
  2. Wire AnonymousSessionMiddleware before CsrfMiddleware in the pipeline. The skeleton's AppKernelFactory does this for you.

๐Ÿ›ก๏ธ SecureContainer

Waffle\Commons\Security\Container\SecureContainer wraps any ContainerInterface and runs the security check before get($id) returns the service โ€” preventing low-privilege code paths from pulling sensitive services out of the container.

analyze($controller, $method) is fail-closed as of Beta-1: an empty #[Voter] list throws SecurityException(403) unless the target carries #[PublicAccess]. Otherwise every voter must approve (consensus pattern) for the call to proceed.

๐Ÿ˜ PHP 8.5 features used

๐Ÿงญ Architectural boundary (mago guard)

An active dependency perimeter is enforced on every CI run by vendor/bin/mago guard (bundled into composer mago; zero baselines). The rules live in mago.toml under [guard.perimeter] โ€” a forbidden use statement fails the build, not a reviewer.

Production code under Waffle\Commons\Security may depend only on:

Test code under WaffleTests\Commons\Security is unrestricted (@all). Structural rules are guarded too: interfaces must be named *Interface, Exception\** classes must end in *Exception, and any Enum\** namespace may hold only enum declarations.

Contract-first, component-agnostic by construction: components compose through waffle-commons/contracts (plus the explicitly-permitted utils), never ad-hoc through one another.

๐Ÿงช Testing

๐Ÿ“š Documentation

Central framework docs live in the waffle-commons/documentation repository:

๐Ÿ“„ License

MIT โ€” see LICENSE.md.


All versions of security with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
waffle-commons/contracts Version self.version
waffle-commons/utils Version self.version
psr/container Version ^2.0
psr/http-factory Version ^1.0
psr/http-server-middleware Version ^1.0
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package waffle-commons/security contains the following files

Loading the files please wait ...